Statalist


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

Re: st: Macro and Loop


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Macro and Loop
Date   Mon, 8 Sep 2008 12:45:17 -0400

Ying Huang <[email protected]>:
You can use -egen- to calculate the max() of all values in some range
of months, but the better approach is outlined in
http://www.stata-journal.com/sjpdf.html?articlenum=pr0004
among other places.

On Mon, Sep 8, 2008 at 12:26 PM, Ying Huang <[email protected]> wrote:
> 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!!
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index