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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.