Search code examples
stringsascharacternumericinformat

SAS not recognizing date format


I have the following character date format:

"3/1990"
"4/1990"
"5/1990"
...

I tried the following code:

data work.temps;
  set indata;
  newdate = input(strip(Date), MMYYSw.);
  rename newdate = date;
run;

I keep on getting the following error meassage: Informat MMYYSW was not found or could not be loaded.


Solution

  • You may have to use a different informat to read in the character dates so that SAS can interpret them as numeric (since dates in SAS are actually numeric values), and then format them as MMYYS..

    This was tested and works for me:

    DATA temps;
    FORMAT newdate MMYYS.;
    SET indata;
    newdate = INPUT(COMPRESS('01/'||date),DDMMYY10.);
    RUN;