[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Incorporating variable labels into the variable name
From
"Michael Blasnik" <[email protected]>
To
<[email protected]>
Subject
Re: st: Incorporating variable labels into the variable name
Date
Thu, 13 Sep 2007 10:49:00 -0400
Note that I had already posted code to solve this problem back on Sep 7. . Here
it is again:
insheet using myfile.csv, nonames
foreach var of varlist _all {
local vname=`var'[1]
local date=date("`vname'","mdy")
if "`date'"!="." {
local year=year(`date')
local monthday:di %dmd `date'
local vname= "rev_"+trim("`monthday'")+"_"+trim("`year'")
}
rename `var' `vname'
}
drop in 1
destring rev_*, replace
Is there some reason you think it doesn't work?
Michael Blasnik
----- Original Message -----
From: "David Elliott" <[email protected]>
To: <[email protected]>
Sent: Thursday, September 13, 2007 9:53 AM
Subject: Re: st: Incorporating variable labels into the variable name
<snip>
If the list of dates continually changes one would have to repeatedly
change the variable renaming. It would be better to have something
that reads the original variable names and does the necessary
manipulation to gt them in the form and then renames the variables
automatically. I think the following will do the trick: (please check
for wrapped lines)
X--------begin---------X
*
* 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 |