Search code examples
sas

How do I change a character value in the format YYMMDD to a date format in PROC FEDSQL


I want to change a column which is in the format YYMMDD (e.g. 130401 to mean 1st April, 2013), into a (numeric) date format. How do I do this in PROC FEDSQL?

In PROC SQL, I would use INPUT(DATE_COLUMN,YYMMDD6.) but I'm not sure how to do it for PROC FEDSQL


Solution

  • Use inputn() to convert it to a numeric SAS date, then cast it to a date to change how it is displayed.

    data foo;
        date_char = '130401';
    run;
    
    proc fedsql;
        select inputn(date_char, 'YYMMDD6.')::date as "date"
        from foo;
    quit;
    
    date
    01APR2013