Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Save results as a data file


From   Ronnie Babigumira <rb.glists@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Save results as a data file
Date   Fri, 15 Sep 2006 22:40:20 +0200

Would this help

x
1
1
2
2
2
3
3
3

bys x: gen freq = _N
collapse freq, by(x) //beware, changes data structure
* You can rename freq to N if you want

Alternatively see -help egen-
Fan, Shihe wrote:
Hi, everyone,

As a new user, could any one show me how to save the results as a data
file so that I can reuse it.
Say, I have a variable (x) with many levels in a file. I want to get
the total count of each level in a file.
The codes;

Sort x;
By x: count;


Will produce the results on the screen, but I want it in a file like:


X N
1 5
2 10
.....



Thank you







Shihe Fan
Epidemiologist
Office of the MOH
Public Health Division
Suite 300, 10216 - 124 Street
Edmonton AB T5N 4A3
Phone:(780) 413-7742
Fax: (780) 413-7950
shihefan@cha.ab.ca

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index