BookmarkSubscribeRSS Feed
racekarrz2
Calcite | Level 5

I have 2 separate variables for age, month and year of birth. I want to categorize it into (40-49, 50-59, 60+).  I am not sure how to format this new variable? I do not have day of birth.

 

Thank you!

1 REPLY 1
Tom
Super User Tom
Super User

@racekarrz2 wrote:

I have 2 separate variables for age, month and year of birth. I want to categorize it into (40-49, 50-59, 60+).  I am not sure how to format this new variable? I do not have day of birth.

 

Thank you!


You need to assume some day of the month for their BIRTH to generate a DATE OF BIRTH. Perhaps the first of the month?

 

You need a second DATE to be able to calculate AGE from a DATE OF BIRTH.   Perhaps the day you run the program?

data want;
  set have;
  dob = mdy(month,1,year);
  age = intnx('year',dob,today(),'s');
  format dob date9.;
run;

To analyze the age groups create a format.

proc format ;
value agegrp
 low-39='Too young'
 40-50='40-50'
 50-59='50-59'
 60-high='60+'
 other='Invalid Age'
;
run;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 133 views
  • 2 likes
  • 2 in conversation