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

st: RE: RE: reshaping with many variables


From   "Radu Ban" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: reshaping with many variables
Date   Fri, 17 Oct 2003 23:31:48 +0100

hi luciana,

i brought the same issued up last month on the list and it was promptly
answered by Nick Cox. basically the problem is you have to list all
stubs, as the varlist abreviation rules don't work for the stubs.

you can take a look at:
http://www.stata.com/support/faqs/data/reshape3.html

which details the problem.

or to cut to the chase, following Nick's advice:

*put all the needed future in a local macro
unab mylist: q*_1

*note that you only need one set of stubs, so that's why you don't use
both 1 and 2

*cut out the "_1" at the end to obtain the actual stubs
foreach v of local mylist {
	local stubs `"`stubs' `=substr("`v'",1,length("`v'")-2)'"' 
} 

*reshape (assuming you have a unique identifier "id")
reshape long `stubs', i(id) j(index) string

*where index will be a new string variable with entries _1 and _2, hence
the string *option

i do hope this helps

-radu

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of SURAN,
LUCIANA
Sent: 17 October 2003 22:52
To: '[email protected]'
Subject: st: RE: reshaping with many variables 


Thanks for the quick response. 
I tried using the ? wildcard term, but I get an error message. For
example, I specified q???_ and the error message says "no xij variables
found."  Does anyone know why this would occur?

Thanks again,
 Luciana

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

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