Drunken Daddy
Drunken Daddy

Reputation: 7991

Issue inputing sas date as datalines

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;

Upvotes: 3

Views: 9705

Answers (1)

Allan Bowe
Allan Bowe

Reputation: 12691

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;

Upvotes: 8

Related Questions