Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2023-06-08 01:04:44
Size: 1419
Comment:
Revision 4 as of 2025-10-24 16:56:41
Size: 1467
Comment: Rewrite
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The '''`contract`''' command creates a dataset of descriptive statistics. '''`-contract-`''' creates a dataset of descriptive statistics.

See [[Stata/AggregatingData|here]] for other similar commands.
Line 41: Line 43:
The `contract` command can compute additional descriptive statistics using these option: `-contract-` can compute additional descriptive statistics using these option:
Line 53: Line 55:
[[https://www.stata.com/manuals/dcontract.pdf|Stata manual for contract]] [[https://www.stata.com/manuals/dcontract.pdf|Stata manual for -contract-]]

Stata Contract

-contract- creates a dataset of descriptive statistics.

See here for other similar commands.


Usage

Given a dataset like:

id

foo

bar

baz

1

0

0

10

2

1

0

20

3

0

0

10

4

1

0

20

5

0

1

10

6

1

1

20

7

0

1

10

8

1

1

20

Running contract foo bar would create a dataset like:

foo

bar

_freq

0

0

2

0

1

2

1

0

2

1

1

2

To rename the frequency variable, try the freq(varname) option.


Statistics

-contract- can compute additional descriptive statistics using these option:

  • cfreq(varname) creates a cumulative frequency, increasing over rows

  • percent(varname) creates a percentage for each row

  • cpercent(varname) creates a cumulative percentage, increasing over rows


See also

Stata manual for -contract-


CategoryRicottone

Stata/Contract (last edited 2025-10-24 16:56:41 by DominicRicottone)