Reading dates into SAS

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 121
Accepted Solution

Reading dates into SAS

I am trying to import the column in the attached file into SAS; I have been using the following code and I am getting an error in the input line. I am using SAS 9.2; could someone provide some insight as to why this doesn't work?

data WORK.NCDebt;

     infile '/SourcePath/Example.csv';

informat Maturity yymmdd8.;

format Maturity yymmdd8.;

input Maturity :yymmdd8.;

run;

Attachment

Accepted Solutions
Solution
‎09-05-2014 01:24 PM
Super User
Posts: 11,134

Re: Reading dates into SAS

Your dates should be read with a mmddyy informat. The while 5 might pass as a year 15 is not a month (the MM part) and 2014 is right out for the day of the month.

and why make an attachment instead of posting:

5/15/2041

5/15/2039

5/15/2038

5/15/2021

5/15/2020

7/2/2015

1/20/2015

11/20/2014

9/16/2014

9/15/2016

View solution in original post


All Replies
Solution
‎09-05-2014 01:24 PM
Super User
Posts: 11,134

Re: Reading dates into SAS

Your dates should be read with a mmddyy informat. The while 5 might pass as a year 15 is not a month (the MM part) and 2014 is right out for the day of the month.

and why make an attachment instead of posting:

5/15/2041

5/15/2039

5/15/2038

5/15/2021

5/15/2020

7/2/2015

1/20/2015

11/20/2014

9/16/2014

9/15/2016

Regular Contributor
Posts: 233

Re: Reading dates into SAS

DATA WORK.Example1;

    LENGTH

        F1                 8 ;

    FORMAT

        F1               YYMMDD8. ;  /** CHANGE THE FORMAT AS YOU NEED TO DISPLAY OUTPUT */

    INFORMAT

        F1               YYMMDD10. ;

    INFILE 'xxxxx/Example.csv'

        LRECL=10

        ENCODING="LATIN1"

        TERMSTR=CRLF

        DLM='7F'x

        MISSOVER

        DSD ;

    INPUT

        F1               : ?? MMDDYY10. ;

RUN;

Capture.JPG

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 163 views
  • 3 likes
  • 3 in conversation