I think what you are looking for might be the -xcontract- utility,
downloadable from SSC using the -ssc- command. If you install this and
type
xcontract X, saving(myresults.dta, replace)
then you will create a dataset in myresults.dta with 1 observation per
value of X and variables X, _freq and _percent, containing the X-value,
frequency and percent, respectively.
I hope this helps.
Roger
Roger Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
www.imperial.ac.uk/nhli/r.newson/
Opinions expressed are those of the author, not of the institution.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Fan, Shihe
Sent: 15 September 2006 21:16
To: [email protected]
Subject: st: Save results as a data file
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
[email protected]
*
* 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/