Now if a date is stored as a number that looks like a date, eg 20170717 (20 million 170 thousand 717), that should be converted to a real SAS date value as early as possible in your analytics chain, preferrably when you read external data. How you do that depends on how data is delivered to you (connection to database, text file, Excel (yucc) file, ...).
If you have a number like that, convert it like this:
startdate = input(put(startdate,8.),yymmdd8.);
format startdate yymmddn8.; /* variable will look the same, but have a different internal value */
format startdate date9.; /* the standard SAS date notation */
format startdate yymmddd8.; /* ISO-compliant notation, used in databases */
format startdate ddmmyyp10.; /* typical in Germany */
format startdate mmddyy10.; /* US and UK */
Use one of the formats that suits you.
Do a Google search for "SAS date values", and one of the first hits will be this https://support.sas.com/resources/papers/proceedings15/1334-2015.pdf, which is a very good paper about how SAS stores date and time values, and how you import, handle and display/export them.
... View more