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]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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