Size: 257
Comment:
|
Size: 1095
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Stata Aggregating Data = | = Aggregating Data with Stata = Stata offers several commands for computing higher-level statistics and translating datasets into aggregated formats. |
Line 9: | Line 11: |
== Contract == | == Contract and Collapse == |
Line 11: | Line 13: |
'''`collapse`''' is ideal for aggregated statistics. | The [[Stata/Contract|contract]] and [[Stata/Collapse|collapse]] commands are ideal for aggregated statistics. The former is useful for descriptive statistics, while the latter is designed for summary statistics. |
Line 14: | Line 16: |
contract VAR, freq(Count) percent(Percentage) | contract foo, freq(Count) percent(Percentage) |
Line 21: | Line 23: |
== Collapse == | == Reshape == The [[Stata/Reshape|reshape]] command can be used to translate datasets between wide and tall 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`. |
Aggregating Data with Stata
Stata offers several commands for computing higher-level statistics and translating datasets into aggregated formats.
Contract and Collapse
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)
Reshape
The reshape command can be used to translate datasets between wide and tall 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.