![]() |
From | Ying Huang <hying@mail.med.upenn.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Macro and Loop |
Date | Mon, 08 Sep 2008 13:13:03 -0400 |
Maarten buis wrote:
--- Ying Huang <hying@mail.med.upenn.edu> wrote:Maarten,
I have 24 indicator variables (1/0) to indicate insurance coverage insay that the indicotor variables are called insured1 till insured24,
24 monthes. For example, if the survey is in 1997, then the survey
month refer to Jan to Dec of 1997, and those 24 variables show
insurance coverage for each month in 97 and 98.
The variable I want to create is again a 1/0 variable, say call it "insurance". Starting from the survey month, if any of the following
12 insurance coverage indicators = yes, then insurance =1; otherwise insurance =0.
then I would type:
egen insured = rowtotal(insured1-insured12)
replace insured = insured >0 if insured < .
You may need to think a bit on how you treat missing values (-rowtotal-
treats a missing value by default as 0)
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* 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/
* * 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–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |