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

st: RE: compact output for series of one-way tabulations


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: RE: compact output for series of one-way tabulations
Date   Mon, 23 May 2005 15:15:11 -0500

Rich,

Do mean something like this:


//Create 32 categorical variables
clear
set obs 10
forv i = 1/32 {
	gen byte x`i' = cond(uniform()<.3 , 1 ,cond(uniform()>.5, 2, 3)) 
}

//Create Frequencies
set obs 14
forv i = 1/32 {
	qui {
	sum x`i' if x`i' == 1
	replace x`i' = r(N)/10 in 11 
	sum x`i' if x`i' == 2
	replace x`i' = r(N)/10 in 12 
	sum x`i' if x`i' == 3
	replace x`i' = r(N)/10 in 13 
	replace x`i' = r(N) in 14
}
}

xpose, clear var
keep v11 - _var
order _v v11
label var v11 "Frequency of ones"
label var v12 "Frequency of twos"
label var v12 "Frequency of threes"
label var v13 "Total number of threes "
l


Scott


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Richard Goldstein
> Sent: Monday, May 23, 2005 2:31 PM
> To: statalist
> Subject: st: compact output for series of one-way tabulations
> 
> I have a set of 32 variables, each can have any of the categorical values.
> What I want is an output that (excluding the header) is 32 rows by 5
> columns,
> where the first column is the variable name and columns 2-4 are the three
> categories (frequency or count) and the last column is the total number
> having
> one of the three categories.
> 
> I admit that I cannot see even how to start coding this so I'm hoping that
> either someone already has coded it (though I couldn't find anything) or
> that
> someone has a hint or two they could share.
> 
> Thanks,
> 
> Rich Goldstein
> 


*
*   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