Issues with Date format in SAS

33 Views Asked by At

I am trying to run the survival analysis, while censoring the data based on variables which are in dates. When I upload the complete dataset, all the date variables are imported as characters and i cannot run analysis on them! Format of the dates in all columns are as 08/19/1990.

Here is my code which is simply uploading the data from excel.

   **proc import datafile='U:/censor_ami.xlsx'
     out= censor Ami
     dbms=xlsx
     replace;
     options MSGLEVEL=I
     run;*

*Please help me sort out this issue!

I need to know how to solve this date format issue in SAS!

1

There are 1 best solutions below

0
Stu Sztukowski On

Usually this happens because the date is formatted as a character in Excel. If for some reason you can't get it to work correctly, you can always convert the date yourself in SAS. I personally prefer to try and use the andydtdte. date format first since it automatically covers a large number of common dates.

data want;
    set have(rename=(date=date2));

    date = input(date2, anydtdte.);

    format date date9.;
    drop date2;
run;