[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Incorporating variable labels into the variable name

From   "David Elliott" <[email protected]>
To   [email protected]
Subject   Re: st: Incorporating variable labels into the variable name
Date   Thu, 13 Sep 2007 13:23:44 -0300

Just an observation, Michael, your solution didn't thread into the
topic in my mail program, although it is properly threaded in the
Archive.  It happens sometimes (actually, all the time) that replies
to threads don't properly thread and can get missed.

I very much like your solution as it is quite parsimonious of code,
although with a different dataset having a number of datatypes the
destringing process might not be as easy.  While I didn't implement it
originally, I think I would simply use the variable label next time
combining some of my code and Michael's to produce:



insheet using c:\ado\test\testfile.raw

foreach V of varlist _all {
  local date=date("`:variable label `V''","mdy")
  if "`date'" !="." { // variable has label in date format
	local year=year(`date')
	local monthday:di  %dmd `date'
	local vname= "rev_"+trim("`monthday'")+"_"+trim("`year'")
	rename `V' `vname'

reshape long rev_ , i(acct) string


I think this combines the best of both approaches.

DC Elliott
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index