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

I have start and stop date in  2016-02-11 and 2016-02-24 formats and i am doing the below code:

data trt1;
set trt;
exp = (SEENDTC-SESTDTC+1);
run;

 

But i get the below error message and i even tried to give format statement but still its not working. any help?

NOTE: Invalid numeric data, SEENDTC='2016-02-24' , at line 161 column 11.
NOTE: Invalid numeric data, SESTDTC='2016-02-11' , at line 161 column 19.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

This is because you do not have a SAS date value, but a string containing a human-readable date.

First convert to a SAS date value:

data trt1;
set trt;
format SEENDTC_num SESTDTC_num yymmddd10.;
SEENDTC_num = input(SEENDTC,yymmdd10.);
SESTDTC_num = input(SESTDTC,yymmdd10.);
exp = (SEENDTC_num - SESTDTC_num + 1);
run;

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

This is because you do not have a SAS date value, but a string containing a human-readable date.

First convert to a SAS date value:

data trt1;
set trt;
format SEENDTC_num SESTDTC_num yymmddd10.;
SEENDTC_num = input(SEENDTC,yymmdd10.);
SESTDTC_num = input(SESTDTC,yymmdd10.);
exp = (SEENDTC_num - SESTDTC_num + 1);
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 5456 views
  • 1 like
  • 2 in conversation