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]

st: RE: Using value labels to create varlist


From   "David Radwin" <[email protected]>
To   <[email protected]>
Subject   st: RE: Using value labels to create varlist
Date   Tue, 12 Mar 2013 16:55:02 -0700 (PDT)

Yo Jack,

Try extended macro functions within a -foreach- loop, like:

foreach v of varlist * {
	if "`: value label `v''" == "LABBG" mvdecode `v', mv(5 6)
	if "`: value label `v''" == "LABA"  mvdecode `v', mv(3)
	}

David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of [email protected]
> Sent: Tuesday, March 12, 2013 4:19 PM
> To: [email protected]
> Subject: st: Using value labels to create varlist
> 
> Yo Statalisters,
> 
> So I got a dataset with about 1,500 (categorical) variables, but about
> 70 value labels mixed in pretty randomly though out the variables. All
> the value labels are slightly different and the categories change from
> one value label to the next (some binary, some likert 5 point scales,
> some 4 etc and so forth). For each variables with the same value label I
> need to send some to missing (for instance with variables with value
> label LABBG - need 5 and 6 to go to missing, for LABA, need 3 to go to
> missing...). The changes are consistent for each variable with the same
> value label...
> 
> Is there a way to pick variables by their value label, alter the
> variable by sending a few values to missing, then picking the next value
> label... appreciate that I'll have to code up _how_ I want each value
> label to behave, but it's the picking of the variables that has got me
> stumped, lookfor doesn't seem to pick them...
> 
> Cheers
> Jack
*
*   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