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: I keep getting this error message: the number of new and transformed varnames should be the same
From
Phil Schumm <[email protected]>
To
<[email protected]>
Subject
Re: st: I keep getting this error message: the number of new and transformed varnames should be the same
Date
Thu, 1 Aug 2013 17:52:41 -0500
On Aug 1, 2013, at 5:20 PM, Jason W <[email protected]> wrote:
> I have been working on a variable that lists the age of the respondents. It runs from 17-99. I want to recode it
> into a dummy variable where 17 to 21 equal 1 and the rest are zeroed out, but I am
> constantly getting this error message when I try to generate the dummy
> variable:
>
> "the number of new and transformed varnames should be the same"
>
> What does this mean and how can I address it?
>
>
> This is the command I tried to enter before getting the
> error message:
> recode VCF0101 17=1 18=1 19=1 20=1 21=1 22=0 23=0 24=0 25=0
> 26=0 27=0 28=0 29=0 30=0 31=0 32=0 33=0 34=0 35=0 36=0 37=0 38=0 39=0 40=0 41=0
> 42=0 43=0 44=0 45=0 46=0 47=0 48=0 49=0 50=0 51=0 52=0 53=0 54=0 55=0 56=0 57=0
> 58=0 59=0 60=0 61=0 62=0 63=0 64=0 65=0 66=0 67=0 68=0 69=0 70=0 71=0 72=0 73=0
> 74=0 75=0 76=0 77=0 78=0 79=0 80=0 81=0 82=0 83=0 84=0 85=0 86=0 87=0 88=0 89=0
> 90=0 91=0 92=0 93=0 94=0 95=0 96=0 97=0 98=0 99=0, gen(young cohort)
The command
gen young = inrange(VCF0101,17,21) if !mi(VCF0101)
will do what you want. The specific error message you got was because you can't recode one variable into two variables. Perhaps you intended "young cohort" to be a variable name (variable names cannot include spaces), or forgot an underscore (i.e., young_cohort).
-- Phil
*
* 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/