Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: -reshape- and variable names involving zero (0)


From   Richard Williams <richardwilliams.ndu@gmail.com>
To   statalist@hsphsun2.harvard.edu, Stata Help <statalist@hsphsun2.harvard.edu>
Subject   Re: st: -reshape- and variable names involving zero (0)
Date   Sun, 27 Oct 2013 17:26:44 -0500

At 03:43 PM 10/27/2013, Roberto Ferrer wrote:
This derived from

http://www.stata.com/statalist/archive/2013-10/msg00949.html

The following does not give the result I would expect:

*------------------------ begin code ----------------------------------------
clear
input id str4 ticker str20 type return06 return07 return08
1 "ABCB" "formation" 0.01 0.2 0.3
2 "AEDU" "formation" 0.02 0.4 0.5
3 "AMBV" "formation" 0.01 0.2 0.3
1 "ABCB" "buysell" 0.01 0.2 0.3
2 "AEDU" "buysell" 0.01 0.2 0.3
3 "AMBV" "buysell" 0.01 0.2 0.3
1 "ABCB" "holding" 0.01 0.2 0.3
2 "AEDU" "holding" 0.01 0.2 0.3
3 "AMBV" "holding" 0.01 0.2 0.3
end

reshape long return, i(id type) j(period)
list
*--------------------- end code ------------------------------------------------

In the output I can see:

xij variables:
                return6 return7 return8   ->   return

which I believe should be:

return06 return07 return08

Notice the zeros are cropped out.

If I rename return06, return07, return08 to
return16, return17, return18, the code returns what I expect.

What am I missing? What's the problem with the original names
and -reshape- ?

You also get this warning message:

. reshape long return, i(id type) j(period)
(note: j = 6 7 8)
(note: return6 not found)
(note: return7 not found)
(note: return8 not found)

I think Stata just doesn't like leading zeroes in the names. I can see where leading zeros would be a problem. Suppose you had both return6 and return06 in your data. What is Stata supposed to do with them?

Somebody else may correct me, but I think you just need to avoid leading zeros in your variable names, e.g. rename your vars return6, return7 and return8. It works fine for me when I do that.

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index