-
Notifications
You must be signed in to change notification settings - Fork 0
/
summarizeby.sthlp
55 lines (42 loc) · 1.7 KB
/
summarizeby.sthlp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{smcl}
{* *! version 1.1.2 07oct2022}{...}
{viewerjumpto "Examples" "summarizeby##examples"}{...}
{title:Title}
{phang}
{bf:summarizeby} {hline 2} Extend {helpb statsby}
for {helpb summarize} with the same syntax but no ": command"
{marker examples}{...}
{title:Examples}
{cmd:. sysuse auto, clear}
* simple example, collect all statistics returned by summarize
{cmd:. summarizeby, clear}
* same example with by()
{cmd:. summarizeby, clear by(foreign)}
* detailed example, collect all statistics returned by summarize
{cmd:. summarizeby, clear detail}
* save main statistics into a DTA file
{cmd:. summarizeby mean=r(mean) sd=r(sd) min=r(min) max=r(max), saving(stats)}
* compare and contrast main statistics for two datasets
{cmd:. tempfile tmpf}
{cmd:. preserve}
{cmd:. summarizeby mean=r(mean) sd=r(sd) if mpg > 20, saving(`tmpf')}
{cmd:. restore}
{cmd:. summarizeby mean=r(mean) sd=r(sd), clear}
{cmd:. append using `tmpf', gen(id)}
{cmd:. order id}
{cmd:. label define dataset 0 "full" 1 "reduced"}
{cmd:. label values id dataset}
* export to excel
{cmd:. export excel * using "stats.xlsx", firstrow(variables)}
{title:Author}
{pstd}
{bf:Ilya Bolotov}
{break}Prague University of Economics and Business
{break}Prague, Czech Republic
{break}{browse "mailto:ilya.bolotov@vse.cz":ilya.bolotov@vse.cz}
{pstd}
Thanks for citing this software and my works on the topic:
{p 8 8 2}
Bolotov, I. (2020). SUMMARIZEBY: Stata module to use statsby functionality with
summarize. Available from
{browse "https://ideas.repec.org/c/boc/bocode/s458870.html"}.