Help using Base SAS procedures

question re: dates - moving DOB to current year

Reply
N/A
Posts: 0

question re: dates - moving DOB to current year

I have a date of birth (DOB) variable (for example: 3/15/02) and need a second variable with the same birth date, but with 2007 as the year (result = 3/15/07).

Any suggestions on how to make this happen?

Thanks!
Respected Advisor
Posts: 3,799

Re: question re: dates - moving DOB to current year

Posted in reply to deleted_user
INTNX will advance a date in that way.

[pre]
1269 data _null_;
1270 /* 3/15/02*/
1271 dob = '15mar2002'd;
1272 dob07 = intnx('year',dob,5,'sameday');
1273 put (_all_)(=date9.);
1274 run;
dob=15MAR2002 dob07=15MAR2007
[/pre]
Respected Advisor
Posts: 3,799

Re: question re: dates - moving DOB to current year

Posted in reply to data_null__
Current year? Maybe this is better. You don't need INTNX/INTCK except for leap day babies.

[pre]
1301 data _null_;
1302 /* 3/15/02*/
1303 do dob='15mar2002'd,'20MAY1988'd,'29feb2008'd;
1304 dobC = intnx('year',dob,intck('year',dob,today()),'sameday');
1305 put (_all_)(=date9.);
1306 end;
1307 run;

dob=15MAR2002 dobC=15MAR2009
dob=20MAY1988 dobC=20MAY2009
dob=29FEB2008 dobC=28FEB2009
[/pre]
Ask a Question
Discussion stats
  • 2 replies
  • 94 views
  • 0 likes
  • 2 in conversation