Thomas Speidel wrote:
I am trying to order the variables of a dataset in a chronological
fashion (the month+year is stored in the the varname - the content of
the variables is _not_ a date). I have to allow for the possibility of
additional variables reflecting future/past dates, hence the lengthy
order command. I am not sure why this is happening, since I thought the
capture option should take care of it, but the following code does not
produce what I had expected:
set obs 10
gen Sector=1
gen Feb2007=2
gen Dec2006=6
gen Oct2006=4
gen Nov2006=84
gen Sep2006=897
gen Jan2007=4.3
....
--------------------------------------------------------
Austin Nichols had a suggestion; here is another:
Use sortable variable names and use -aorder- to sort them:
gen v2007_02=2
gen v2006_12=6
gen v2006_10=4
gen v2006_11=84
gen v2006_09=897
gen v2007_01=4.3
aorder
Hope this helps
Svend
__________________________________________
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C, Denmark
Phone: +45 8942 6090
Home: +45 8693 7796
Email: [email protected]
__________________________________________
*
* 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/