DATA Step, Macro, Functions and more

invalid numeric data error in date

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

invalid numeric data error in date

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.


Accepted Solutions
Solution
‎03-03-2017 03:58 AM
Super User
Posts: 6,928

Re: invalid numeric data error in date

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎03-03-2017 03:58 AM
Super User
Posts: 6,928

Re: invalid numeric data error in date

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 197 views
  • 1 like
  • 2 in conversation