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: How to apply a command to numeric variables only
From
"Paul O'Brien" <[email protected]>
To
[email protected]
Subject
Re: st: How to apply a command to numeric variables only
Date
Sat, 2 Jun 2012 09:47:44 +0100
That's great Nick, thanks.
The last thing is to restore the variable labels, which are lost in the new variables.
The labels were 'SRH Care Activity 4', 'SRH Care Activity 5' and 'SRH Care Activity 6', although in another dataset the number of variables I have to decode could be between 2 and 4.
Is there a way to remember the labels and reapply them to the new variables?
Paul
On 30 May 2012, at 00:57, Nick Cox wrote:
>
> Your problem was posed that you want to -decode- variables, except
> that you can't -decode- string variables. But you can't -decode-
> variables without value labels either. So let's suppose you just want
> a string version.
>
> foreach var in `r(varlist)' {
> capture decode `var', generate(work)
> if _rc gen work = string(`var')
> drop `var'
> rename work `var'
> }
>
-------------------------------
Dr Paul O'Brien
Raymede Clinic
Westside Contraception and Sexual Health Services
Central London Community Healthcare
Exmoor St
London
W10 6DZ
UK
+44 (0)20 8962 4450
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/