Hi Can someone help me with using the informat for this date ?
Feb 5 2019 12:00AM
Also I need the output in mmddyy10. format?
Thanks in advance
If your datetime comes in this form consistently, the anydtdtm. informat will work:
data want;
indate = 'Feb 5 2019 12:00AM';
outdate = datepart(input(indate,anydtdtm20.));
format outdate mmddyy10.;
run;
proc print data=want noobs;
run;
Result:
indate outdate Feb 5 2019 12:00AM 02/05/2019
So you want to read the string "Feb 5 2019 12:00AM" as a date or a datetime value?
If your datetime comes in this form consistently, the anydtdtm. informat will work:
data want;
indate = 'Feb 5 2019 12:00AM';
outdate = datepart(input(indate,anydtdtm20.));
format outdate mmddyy10.;
run;
proc print data=want noobs;
run;
Result:
indate outdate Feb 5 2019 12:00AM 02/05/2019
If you want to keep the value as a datetime value you can use a custom format. Example:
Proc format library=work; picture dtmmddyy (default=10) low-high ='%0m/%0d/%Y' (datatype=datetime) ; run; data example; x='02FEB2019:10:15:15'dt; put x dtmmddyy.; run;
SAS does supply a number of other formats to display the date portion of datetime values such as DTDATE, DTMONYY and a couple of others. So this is not an off the wall solution.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.