Date informats and formats

Senast ändrad: 03 oktober 2019

Date informats and formats

When we read dates we need to define which kind of date we insert (e.g. ddmmyy10.). SAS handles dates afterwards as numeric variables counting days since Jan 1st 1960. To again express a date in a date format you can use  

format date: ddmmyy10.;

Try this:

proc print data=indata1;
format date:yymmdd10.;
run;

 Here are some other date formats:

  • DDMMYYw.
  • day, month, year (w. gives the number of characters, above we use 10, try 8 and check the difference)
  • YYMMDDw.
  • year, month, day (often used in Sweden)
  • MMDDYYw.
  • month, day, year
  • DATEw.
  • day, month abbreviation, year
  • DAYw.
  • day of month
  • DOWNAMEw.
  • name of the day of the week
  • JULDAYw.
  • day of the year (e.g. 32 for the 1st of February)
  • ANYDTDTEw.
  • used to read data from a file. SAS tries to finds a suitable date format by itself.

 


Kontaktinformation