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

Hello, I am trying to calculate an age variable.

 

The input format of brth_date (birth date) and scrn_date (screening date) is datetime 22.3.

the output format is numeric best12.

 

I am receiving the error: "Invalid character data" (Log below) 

Any help would be appreciated.

 

Thank you!!

 

Capture.PNG

 

brth_date = datepart (brthdat);

if recorddate > . then scrn_date = datepart (recorddate);
else scrn_date = datepart (icdat);

age = floor(yrdif (brth_date, scrn_date,'age'));
1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Could you please check if you have the age already derived in DM1 dataset. 

 

Thanks,
Jag

View solution in original post

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

Could you please check if you have the age already derived in DM1 dataset. 

 

Thanks,
Jag
mglogan
Obsidian | Level 7

Wow, so when I initialized the variables in the dm1 data set, I accidentally set age = ' ' instead of age = . 

 

Thank you!  

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1387 views
  • 1 like
  • 2 in conversation