Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: gen a variable


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: gen a variable
Date   Thu, 22 Mar 2012 16:54:08 +0100

Chiara,

Nick and Maarten already pointed to -egen- as a possible solution.

Aside from your question I would like to add, that expressions like

if cond3==1 & age>=15 & age<=64 & dipind==1 & hours>20 & hours<55 &
occupation==1

may in a lot of cases be easier written using -inlist() and
-inrange()- function as in

if  inlist(1, cond3, dipind, occupation) & inrange(age, 15, 64) &
inrange(hours, 20, 55)

Note however that -inrange(z, a, b)- returns one if a <= z <= b.

Best
Daniel
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index