Statalist The Stata Listserver


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

st: RE: RE: reshape, dropping empty variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: reshape, dropping empty variables
Date   Wed, 3 May 2006 18:20:43 +0100

Alternatively, 

. search dropmiss 

Nick 
[email protected] 

Alex Ogan
 
> You might want something like:
> 
> ds 
> foreach var in `r(varlist)' {
> 	capture confirm numeric variable `var'
> 	if _rc==0 {
> 		quietly sum `var'
> 		if r(N)==0 drop `var'
> 	}
> }
 
daphna bassok
 
> I am having a bit of challenging time with the reshape command in 
> stata, and was hoping someone had some advice.
> 
> I have 8 years of data, and it is currently in long format. I have a 
> large number of variables in the dataset.  Some of the variables have 
> data for all eight years, but many have data only for 2002-2005  or 
> alternatively only for 1998-2001.  Therefore, when I reshape the data 
> from long to wide, I end up with a huge number of "empty" variables, 
> that have no values at all, and are therefore unnecessary.
> 
> I am looking for a way to drop all these empty variables, without 
> inspecting one at a time.
> 
> Is there a quick way to do  this?
> 

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