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.

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!

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
  • 4 replies
  • 1262 views
  • 0 likes
  • 2 in conversation