BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
2 REPLIES 2
data_null__
Jade | Level 19
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]
data_null__
Jade | Level 19
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]

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 759 views
  • 0 likes
  • 2 in conversation