Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Macro and Loop


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:

I have 24 indicator variables (1/0) to indicate insurance coverage in
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.
say that the indicotor variables are called insured1 till insured24,
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,
Thanks a lot for your reply, but what I want to know is not if someone had coverage for any of all those 24 months. What I want to know is if someone had coverage from Aug 97 to Aug 98 if he was surveyed in Aug 97. For another person, the period may go from Nov 97 to Nov 98. The 12-month period varies from person to person.




-----------------------------------------
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index