Differences between revisions 10 and 11
Revision 10 as of 2023-06-09 16:51:50
Size: 1282
Comment:
Revision 11 as of 2025-10-24 16:26:08
Size: 1301
Comment: Rewrite
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
The [[Stata/Summarize|summarize]] command computes and [[Stata/StoredResults|stores]] descriptive statistics. The [[Stata/Summarize|-summarize-]] command computes and [[Stata/StoredResults|stores]] descriptive statistics.
Line 15: Line 15:
The [[Stata/Inspect|inspect]] command is useful for interactive exploration. The [[Stata/Inspect|-inspect-]] command is useful for interactive exploration.
Line 17: Line 17:
The [[Stata/Contract|contract]] and [[Stata/Collapse|collapse]] create datasets of aggregated statistics. The former is useful for descriptive statistics, while the latter is designed for summary statistics. The [[Stata/Contract|-contract-]] and [[Stata/Collapse|-collapse-]] commands create datasets of aggregated statistics. The former is useful for descriptive statistics, while the latter is designed for summary statistics.
Line 29: Line 29:
The [[Stata/Reshape|reshape]] command can be used to translate datasets between wide and long formats. The [[Stata/Reshape|-reshape-]] command can be used to translate datasets between wide and long formats.

Aggregating Data with Stata

Stata offers several commands for computing aggregated statistics and translating datasets into aggregated formats.


Statistics

The -summarize- command computes and stores descriptive statistics.

The -inspect- command is useful for interactive exploration.

The -contract- and -collapse- commands create datasets of aggregated statistics. The former is useful for descriptive statistics, while the latter is designed for summary statistics.

contract foo, freq(Count) percent(Percentage)


Wide and Long Data

The -reshape- command can be used to translate datasets between wide and long formats.

To translate into a wide format, try:

reshape wide VARSTUB, i(KEYVAR) j(GROUPVAR)

A series of variables named like VARSTUB* will be created, for each group of GROUPVAR.

To translate into a long format, try:

reshape long VARSTUB, i(KEYVAR) j(GROUPVAR)

The variable VARSTUB will be created from the variable list VARSTUB*, and GROUPVAR will be created to indicate the source of VARSTUB.


CategoryRicottone

Stata/AggregatingData (last edited 2025-10-24 16:26:08 by DominicRicottone)