Date: Wed, 18 Apr 2007 19:50:34 -0700
Reply-To: proc sas <sumanta24@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: proc sas <sumanta24@GMAIL.COM>
Organization: http://groups.google.com
Subject: Help in creating new variable
Content-Type: text/plain; charset="iso-8859-1"
Hi All,
I have a dataset like this:
app_num mon yr age
111 1 2004 0
111 2 2004 1
111 3 .
111 12 2004 11
111 1 2005 12
111 .
111 40
222 5 2004 0
222 6 2004 1
222 .
222 .
222 40
Now i need to calculate variable mm and tyr such that,
when mon=1 and yr=2004 and age=0 then mm=1 and tyr=2004
when mon=1 and yr=2004 and age=1 then mm=2 and tyr=2004
...............
when mon=1 and yr=2004 and age=11 then mm=12 and tyr=2004
when mon=1 and yr=2005 and age=12 then mm=1 and tyr=2005
I have this data for several app_num, whose starting point may vary,
like for app_num=111,
mon=1 and year=2004
for app_num=222,
mon=5 and year=2005.
For app_num the condition will be,
when mon=5 and yr=2005 and age=0 then mm=5 and tyr=2005
when mon=5 and yr=2005 and age=1 then mm=6 and tyr=2005
.............
when mon=5 and yr=2005 and age=7 then mm=12 and tyr=2005
when mon=5 and yr=2005 and age=8 then mm=1 and tyr=2006
How simply i can develop this logic? f i'm unable to make you
understand please feel free to ask me questions.
Thanks.