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

I am dealing with a situation where I have 2 different date formats. One is a full date formatted as yymmdd8. The other is just a year formatted as BEST12. I need to do a subtraction to calculate age at the event and select cases higher than a certain age. Please advise a solution.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You just need to define what your algorithm is for defining age at event.  The simplest is to just use the year from the event.

age_at_event = year(event_date) - year_of_birth ;

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

One way is to transform YEAR into a SAS date, say the first of April of that year with MDY(4, 1, YEAR) and then use function YRDIF to calculate the age. Assuming DATE is greater than MDY(4, 1, YEAR) :

if yrdif( mdy(4, 1, year), date, "AGE" ) > ageLimit;

PG

PG
Tom
Super User Tom
Super User

You just need to define what your algorithm is for defining age at event.  The simplest is to just use the year from the event.

age_at_event = year(event_date) - year_of_birth ;

sanketshah07
Obsidian | Level 7

Tom,

This was very helpful and it solved the problem. Thank you for your time. I really appreciate the help.

Sanket

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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