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: RE: data management: looking for the shortest way


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: data management: looking for the shortest way
Date   Thu, 24 Oct 2013 11:35:14 +0200

You gave an expression. The result of that expression is a set of
zeros (false) and ones (true). However, you did not tell Stata what to
do with the results of that expression. How is Stata to know that you
want to make an indicator variable? (Some prefer the name dummy
variable, but not me.) Even if it knew that, how is Stata to know what
name you want that variable to have?

I think what you want is:

gen leap_year = (mod (YEAR,4) == 0 & mod(YEAR, 100) !=0) | mod(YEAR,400) == 0

or better:

gen byte leap_year = (mod (YEAR,4) == 0 & mod(YEAR, 100) !=0) |
mod(YEAR,400) == 0

-- Maarten

On Thu, Oct 24, 2013 at 11:21 AM, PAPANIKOLAOU P.
<P.Papanikolaou@swansea.ac.uk> wrote:
> Dear All,
> Thank you for emailing me how to translate the YEAR into a LEAP_YEAR
> dummy.
>  However,  I followed this thru, the FAQs relevant section, and STATA
> still is not happy.
> Please, see below.
>
> . (mod (YEAR,4) == 0 & mod(YEAR, 100) !=0) | mod(YEAR,400) == 0
> unrecognized command:  ( invalid command name
> r(199);
>
>
> Your feedback would be very welcome and much appreciated.
> Thank you so much
> Panos
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: 24 October 2013 09:27
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: RE: data management: looking for the shortest way
>
> This is an FAQ:
>
> http://www.stata.com/support/faqs/data-management/leap-year-indicators/
>
> The Statalist FAQ itself suggests search of the Stata FAQs.
>
> Note also
>
> http://www.stata.com/support/faqs/resources/statalist-faq/#spell
>
> Nick
> njcoxstata@gmail.com
>
>
> On 24 October 2013 09:19, PAPANIKOLAOU P. <P.Papanikolaou@swansea.ac.uk>
> wrote:
>
>> I have a variable YEAR of BIRTH  and want to create a dummy variable
>> taking the value 1 if the individual was born in a LEAP year and 0
>> otherwise.
> *
> *   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/



-- 
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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