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!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: