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.
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;
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.