data final3;
set final2;
dt = input(put(date, 8. -l), yymmdd10.);
edt = input(put(edate, 8. -l), yymmdd10.);
dd = dt - edt;
run;
Try that.
I think you have a date that's a number but not a SAS date,
ie 2019/11/20 is shown as the number 20191120 not a SAS date. So first convert it to a character and then re-read it as a SAS date. There are other ways to do this but this is one way.
@Xinhui wrote:
Hi there
I'm attempt to calculate the days between varible 'date' and 'edate', I used following codes:
data final3; set final2; dt = input(date, yymmdd10.); edt = input(edate, yymmdd10.); dd = dt - edt; run;
It works before, but for somereason, it not work anymore.
the log information shows that
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
622:12 623:13
NOTE: Invalid argument to function INPUT at line 623 column 7.
Company_Name=ARCHER-DANIELS-MIDLAND CO TICKER=ADM EDATE=20140204 Date=20100107 Price=31.23 dt=22189 edt=. dd=.
_ERROR_=1 _N_=4
NOTE: Invalid argument to function INPUT at line 623 column 7.
Company_Name=ARCHER-DANIELS-MIDLAND CO TICKER=ADM EDATE=20150203 Date=20100108 Price=30.84 dt=22189 edt=. dd=.
_ERROR_=1 _N_=5
I don't know why it not work in this case.
I suspect that maybe the format of the "date" and "edate" has some problem.
Thanks in advance.
... View more