Statalist


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

st: Macro and Loop


From   Ying Huang <hying@mail.med.upenn.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Macro and Loop
Date   Mon, 08 Sep 2008 12:26:20 -0400

Dear all,

I am stuck in a Stata programming problem in work, and I wonder if you can help me out. I am working on a survey data right now and the data is in person level. And we want to see if a sample person had some kind of insurance coverage during a one-year period starting from the survey.

The first variable is the month of survey. It's numeric and goes from 1 to 12. And then 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.

I guess this would involve a macro and a forvalues loop. I tried to generate local macro a = interview month and b = interview month +12; then I tried to put "a" and "b" in a forvalues loop. But it did not work.

Thanks a lot for your help!!

Ying
*
* 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