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

I'm using this code to calculate age in months using two different methods:

x_age_mn_m1 = intck("month", dob, 1_date)+0.5;
x_age_mn_d1 = intck ("day", dob, 1_date)/30.43;

 

x_age_mn_m2 = intck("month", dob, 2_date)+0.5;
x_age_mn_d2 = intck ("day", dob, 2_date)/30.43;

 

The code works fine, but there are improbable values generated for the age_mn variables (x_age_mn_m1  and x_age_mn_d1) one of the inputs, only one!

Why does this happen, and how can I solve it? Thanks!

 

IDDOB1_datex_age_mn_m1 x_age_mn_d1 2_datex_age_mn_m2

x_age_mn_d2

z05/23/201203/30/301712058.512060.9305/15/201760.5

59.744

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

Did you intend for that date to be almost 1,000 years in the future?

03/30/3017

 

Jim

View solution in original post

3 REPLIES 3
jimbarbour
Meteorite | Level 14

Did you intend for that date to be almost 1,000 years in the future?

03/30/3017

 

Jim

SASKiwi
PROC Star

If you want to count calendar months rather than month boundaries then use this option:

x_age_mn_m1 = intck("month", dob, 1_date, 'C');

 

Reeza
Super User
Look at the FOURTH parameter for the INTCK function which allows you to control how the calcuation occurs in a little more detail.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 527 views
  • 5 likes
  • 4 in conversation