From | Ronán Conroy <[email protected]> |
To | [email protected] |
Subject | Re: st: if/else command |
Date | Thu, 06 Jan 2005 15:28:06 +0000 |
Ulrich Kohler wrote:
Moreover, in SPSS "generating" and "replacing" can be done with the sameAnother solution is to use -recode-, which is less prolix
command. In Stata there are two. -generate- generates a new variable,
-replace- changes the contents of an existing variable. You cannot generate a
non-existing variable with -replace-.
All togheter what you want might be something like this:
gen age = 22 if age <= 5 & certification == 1 ;
replace age = 30 if age >= 6 & age <= 15 & certification == 1 ;
replace age = 40 if age >= 16 & age <= 20 & certification == 1 ;
replace age = 50 if age > 20 & certification == 1 ;
--
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |