Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: outsheeting highest frequency values


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: outsheeting highest frequency values
Date   Thu, 27 Oct 2005 09:36:35 +0200

Sean wrote:
> Dear Statalisters,
>
> I have a quick question: there are 20 variables, and I want to tab
> each variable's values in frequency from high to low, and exporting
> each variable's first 10 highest frequency values into a spreadsheet.
> What commands am I supposed to use?

Something along the line of 

. preserve 
. foreach var of varlist v1-v20 {
.	gen n = !mi(`var')
.	collapse (count) n, by(`var')
.	sort n
.	outsheet `var' using `var'.tsv in 1/10
.	restore, preserve
.}


You might also use some -listtex- instead of -outsheet- to produce the 
frequency tables. 

Many regards
uli


-- 
[email protected]
+49 (030) 25491-361
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index