Differences between revisions 8 and 9
Revision 8 as of 2023-06-07 19:49:58
Size: 1093
Comment:
Revision 9 as of 2023-06-07 19:53:48
Size: 1093
Comment:
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
== Contract and Collapse == == Statistics ==
Line 23: Line 23:
== Reshape == == Wide and Long Data ==
Line 25: Line 25:
The [[Stata/Reshape|reshape]] command can be used to translate datasets between wide and tall 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 contract and collapse commands are ideal for 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 2023-06-09 16:51:50 by DominicRicottone)