BookmarkSubscribeRSS Feed
BabyWS77
Calcite | Level 5

Hi all,

 

I have a set of data with customer name, birth_date. I need to create a few new variables, Bday2009, BdayDOW2009 and Age2009.

How shall I write the codes?

  • Bday2009 is the combination of the month of Birth_date, the day of Birth_date and the constant of 2009 in the MDY function.
  • BdayDOW2009 is the day of week of Bday2009,
  • Age2009 is the age of the customer in 2009, Subtract Birth_date from Bday2009 and divide the result by 365.25.

 

Pardon as I am new to SAS and this is my school assignment which am now having diffculities in solving. Thanks advance for any help given.

 

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Show us examples of what you have tried.

--
Paige Miller
BabyWS77
Calcite | Level 5

Hi,

 

the Birth_date is in date9, format (example; 12July1974),

i am stacked at creating the Bday2009 variables as I need to combine the day and month of birth_date with a constant year of 2009,

 

i tried:

Birth_date=myd(month,3, day,2, year,4);

year= ‘2009’;

Bday2009=day month year;

run;

 

Tried several ways but still can’t get it...

PaigeMiller
Diamond | Level 26
bday2009=mdy(month(birth_date),day(birth_date),2009);
--
Paige Miller
BabyWS77
Calcite | Level 5

Ok, will try it. Thanks for the help.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1955 views
  • 0 likes
  • 2 in conversation