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

st: reshaping a large number of variables


From   "Ban,R (pgt)" <R.Ban@lse.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: reshaping a large number of variables
Date   Sat, 20 Sep 2003 17:45:58 +0100

Dear all,
 
I need a bit of help reshaping a large number of variables. In my dataset I have a lot (>100) variables
ending in "v1", "v2", or "v3", representing variables for village 1, 2, or 3. Is there a quick way to reshape all these variables from this wide format into a long format, where each observation corresponds to a single village?
 
I was thinking to do something along this line:
*put all variable names in a local macro
unab mylist : *v1 *v2 *v3
 
*eliminate the trailing number from each name and put new names in a new local macro
*not sure how to do this
 
*reshape using the new local macro
reshape long `newlist', i(id) j(villagenr)
 
 
Any help is greatly appreciated.
 
-radu ban 
 
     
 
 

*
*   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–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index