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]

Re: st: Cannot generate a dummy variable using if command


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Cannot generate a dummy variable using if command
Date   Fri, 2 Aug 2013 14:13:44 -0400

There is nothing wrong.
Type summarize age and look at the min age reported.

A simpler and more robust version is something like:
gen old=age>25 if !missing(age)
Finally note that in nlsw88 dataset (if you are using it) there are no
individuals younger than 34.
Best, Sergiy

On Fri, Aug 2, 2013 at 2:05 PM, Joseph Kwan <[email protected]> wrote:
> I would like to generate a variable for people older than 25 years old,
>
> so I use
>
> gen old=1  if age>25
>
> but then Stata returns with an old dummy variable with all 1 for all observations.
>
> I checked the syntax and I do not know what is wrong.
>
> Is Stata known to have faults like that?
>
> *
> *   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/
*
*   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