BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

I need to calculate when this person turned 6 and then count the the number of days from the servedate to the date he turned six, essentially TurnedSix-Servedate (expressed in days)

 

data temp;
infile datalines dsd missover;
informat dob servedate mmddyy8.;
input dob servedate;
cards;
10/20/10, 01/20/16
;
run;
proc print;
format dob servedate mmddyy.;
run;
data need;
set temp;
TurnedSix= ;
DaysServed= ;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use INTNX to increment the birthdate 6 years.

 

date_6years = intnx('year', dob, 6, 's');

date_diff = servedate - date_6years;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Date person turns 6 can be computed with the INTNX function, or just by incrementing the year by 6.

 

Since the variables of interest are already SAS date values (am I correct about this?), all you have to do is do the subtraction and you will know the number of days. You could also use INTNX, but subtraction is simpler.

--
Paige Miller
Reeza
Super User

Use INTNX to increment the birthdate 6 years.

 

date_6years = intnx('year', dob, 6, 's');

date_diff = servedate - date_6years;

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1750 views
  • 0 likes
  • 3 in conversation