3
votes

I've the following code. Though I've entered 30jun1983 it gets saved as 30/jun/2020. And it is reading only when there's two spaces between the date values in the cards and if there's only one space it reads the second value as missing.

DATA DIFFERENCE;
infile cards dlm=',' dsd;
INPUT  DATE1 DATE9. Dt2 DATE9.;
FORMAT DATE1 DDMMYY10. Dt2 DDMMYY10.;
DIFFERENCE=YRDIF(DATE1,Dt2,'ACT/ACT');
DIFFERENCE=ROUND(DIFFERENCE);
CARDS;
11MAY2009  30jun1983
;
RUN;
1

1 Answers

8
votes

You need colons on your input statement (to denote INformats), and also a comma in your datalines (you specified a comma as your DLM - delimiter):

DATA DIFFERENCE;
infile cards dlm=',' dsd;
INPUT  DATE1 :DATE9. Dt2 :DATE9.;
FORMAT DATE1 DDMMYY10. Dt2 DDMMYY10.;
DIFFERENCE=YRDIF(DATE1,Dt2,'ACT/ACT');
DIFFERENCE=ROUND(DIFFERENCE);
CARDS;
11MAY2009,30jun1983
;
RUN;