BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Lapis Lazuli | Level 10

Hi guys, 

suppose to have the following: 

data DB;
  input ID :$20. Date_of_Birth :date09. Age_of_class1  Age_of_class2; 
  format Date_of_Birth date9.;
cards;
0001 01JUL1938  85  89
0002 01JUL1977  50  54
0003 01JUL1928  55  60
; 
run;

Is there a way to get the following? 

 

data DB1;
  input ID :$20. Date_of_Birth :date09. Age_of_class1  Age_of_class2 Bday_class1 :date9. Bday_class2 :date9.; 
  format Date_of_Birth date9. Bday_class1 date9. Bday_class2 date9.;
cards;
0001 01JUL1938  85  89  01JUL2023  01JUL2027
0002 01JUL1977  50  54  01JUL2027  01JUL2031
0003 01JUL1928  55  60  01JUL1983  01JUL1988
; 
run;

In other words given the birthday date (date_of_birth), how can I get the date (Bday_class1 and Bday_class2) when each ID will have the age shown in Age_of_calss1 and Age_of_class2 variables? 

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Here is code to compute bday_class1. Since I am lazy, I will leave it up to you to write the code for bday_class2.

 

data want;
    set db;
    bday_class1=intnx('year',date_of_birth,age_of_class1,'s');
    format bday_class1 date9.;
Run;

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Here is code to compute bday_class1. Since I am lazy, I will leave it up to you to write the code for bday_class2.

 

data want;
    set db;
    bday_class1=intnx('year',date_of_birth,age_of_class1,'s');
    format bday_class1 date9.;
Run;

 

--
Paige Miller
ballardw
Super User

Suggestion: Provide RULES based on values and variable names, not just examples.

Reasons: 1) Programs are rules.

2) Code that will duplicate an example may not extend to any other values.

3) We don't have to guess what the intent is.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 932 views
  • 2 likes
  • 3 in conversation