Date: Sat, 13 May 2006 12:30:02 -0500
Reply-To: Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Subject: Re: Event History Part II
Content-Type: text/plain; charset=US-ASCII
Matt:
The reason that you get all 0, I believe, is the statement *leave*.
This forces the execution to go out of the outer do loop. Change your
code to the following to see if it works.
do i=2 to 48;
if inter[i] eq 1 then do;
do j=i to 48;
intermig[j]=1;
cminter[j]=interview[i];
end;
leave;
end;
else do;
intermig[i]=0;
cminter[i]=0;
end;
end;
J S Huang
1-515-557-3987
fax 1-515-557-2422
>>> Matt <mshall2@GMAIL.COM> 05/13/06 12:14 PM >>>
I am compiling a migration history database using SIPP data for about
220,000 respondents over 48 months. I have a monthly indicator
(inter[i]) of whether a migration occured or not, and I have computed
a
variable (intermig[i]) that represents whether a migration has
occurred
in the past. I now need to compute a measure of the date of migration,
and have that variables stay be constant by migration. Here's an
example of what I want the data to look like (in long format).
t inter intermig cminter interview
0 0 0 0 616
1 0 0 0 617
2 1 1 618 618
3 0 1 618 619
4 0 1 618 620
5 0 1 618 621
6 0 1 618 622
My data is currently in wide format and so the code below effectively
creates 'intermig,' but the second part where cminter is computed does
not work, and I get zeros on all obs.
Is SAS not able to process the cminter[j]=interview[i] command?
Thanks for your help.
/*Interstate Migrants*/
do i=2 to 48;
if inter[i] eq 1 then do;
do j=i to 48;
intermig[j]=1;
end;
leave;
end;
else intermig[i]=0;
if inter[i] eq 1 then do;
do j=i to 48;
cminter[j]=interview[i];
end;
leave;
end;
else cminter[i]=0;
end;