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

RE: st: RE: Reshape problem.


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Reshape problem.
Date   Mon, 17 Nov 2003 17:09:50 -0000

I doubt that your -reshape- is treating the explicit values 

01 02 ... 10 

literally as strings in the way you wish. 
To Stata 01 02 ... is an acceptable way of specifying 
1 2 ..., just as 0.1 is an acceptable way of 
specifying .1, but that's not what you want. 

Stata is looking in turn for variables of the form 

<stub>1 <stub>2 ... <stub>10 

but it only finds those of the form 
<stub>10, hence the much reduced dataset you got. 

So you really need the literal string interpretation "01" etc. 
and there is a -string- option for this purpose. 

Perhaps Stata should be better at catching this, 
but it's quite tricky given Stata's general 
rules. 

Note also an explicit warning embedded within 
http://www.stata.com/support/faqs/data/reshape3.html: 

"On occasion, people use numeric suffixes with leading zeros, 
such as 01, 02, and so forth. -reshape- will understand 
these properly only if they are declared as string." 

In short, try 

. reshape long $varx, i(wid) j string 

Nick 
[email protected] 

[email protected]
> 
> Hi Shigui,
> It is true. I am using a dhs data. I understand the figure 
> but I think that once
> I
> provide some summary statisctics, you will understand my problem:
> 
> >
> > . global varx "bidx_ bord_ b0_ b3_ b4_ b5_ b7_ b11_ "
> > . global varx2 "bidx bord b0 b3 b4 b5 b7 b11"
> > . reshape long $varx, i(wid) j(j 01 02 03 04 05 06 07 08 09 10)

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