I am testing on conversion of string to date with the following code:
%sysmstoreclear;
data test2;
dt1="05/DEC/2019";
dt2="30/SEP/2020";
dt3="05/dec/2020";
num1=input(dt1,date9.);
num2=input(dt2,date9.);
num3=input(dt3,date9.);
run;
the result is shown in the below picture, num1 and num3 have same value. Can anyone please advise what is the reason caused this?
Hello @tinaz5012 and welcome to the SAS Support Communities!
The date9. informat reads only the first 9 characters of the strings dt1, dt2, dt3, e.g., "05/DEC/2019" (i.e., 5th December 2020). Use the date11. informat to read all 11 characters.
Hello @tinaz5012 and welcome to the SAS Support Communities!
The date9. informat reads only the first 9 characters of the strings dt1, dt2, dt3, e.g., "05/DEC/2019" (i.e., 5th December 2020). Use the date11. informat to read all 11 characters.
data test2;
dt1="05/DEC/2019";
dt2="30/SEP/2020";
dt3="05/dec/2020";
dt4="30/SEP/2021";
num1=input(dt1,date11.);
num2=input(dt2,date11.);
num3=input(dt3,date11.);
Num4=input(dt4,date11.);
format num1 num2 num3 num4 MONYY.;
run;
the date9 format. take only the first nine numbers of the date to get them all use the date11., according to the code below I used Format to debug and show that date11. really is it works.
@FreelanceReinh @ree @juanormelli Thank you all for kindly help, appreciate it!
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.