09-29-2015 08:19 AM
I am reading dataset in a sas program (stored process) which was created from another system. This file has some of the date column formats defined as 'IS8601DN10' and informat as 'DateTime20'. In viewing the table, the date displays as 'YYYY-MM-DD'. I am trying to format the date to the format of 'mm/dd/yyyy' and I have not been successful in doing so. I've spend several hours on this and am quite frustrated. Any help/suggestions would be greatly appreciated!
I have never seen any data come in that used this 'IS860' type format.
Thanks for any help that can be offered!!!
09-29-2015 09:15 AM
When you are using the IS8601DN10 (documented as E8601DN format), you are actually have a datetime value. So to display it using the MMDDYY. format you need to extract just the date part of the datetime value.
The code below illustrates this.
data sample; xDate = datetime(); xDate2 = datepart( xDate ); format xDate IS8601DN10. xDate2 mmddyy10. ; run; proc print data=sample ; run;
09-29-2015 10:41 PM
I like Bruno's answer better than mine, since it forces you to understand what is in your data. With that being said, you have enough to work with once you understand that expressing your variable in the IS8601DN10 format gives you YYYY-MM-DD. Knowing just that much, you could code:
newvar = (put(oldvar, IS8601DN10.), yymmdd10.);
That gives you NEWVAR as a SAS date, without even knowing what is in OLDVAR. Just add a format:
format newvar mmddyys10.;