Statalist The Stata Listserver

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

st: RE: Save results as a data file

From   "Newson, Roger B" <>
To   <>
Subject   st: RE: Save results as a data file
Date   Sun, 17 Sep 2006 13:49:19 +0100

I think what you are looking for might be the -xcontract- utility,
downloadable from SSC using the -ssc- command. If you install this and

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 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
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
[] On Behalf Of Fan, Shihe
Sent: 15 September 2006 21:16
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:

1	5
2	10

Thank you

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

*   For searches and help try:

*   For searches and help try:

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