Dear all,
I am looking for the way to convert character date value to numeric date value like below shown
What I wanted is to have TO_DATE from 22/04/2023 in numeric form transferred to 22APR2023 in numeric form.
here is my code attempt to do so but failed. any suggestion would you advice to me?
DATA mydata4;
SET mydata3;
FROM_DATE2=input(FROM_DATE,DDMMYY10.);
TO_DATE2=input(TO_DATE,DDMMYY10.);
FROM_DATE3=put(FROM_DATE2,DATE9.);
TO_DATE3=put(TO_DATE2,DATE9.);
RUN;
Thanks in advance.
regards,
Harry
22/04/2023 in "numeric" form is twenty-two divided by four divided by two thousand and twenty-three and so has nothing to with a date value.
The number in your PICTURE looks to be 23,122 (twenty-three thousand one hundred and twenty-two).
If you want that number to PRINT as 22APR2023 then just print it using the DATE9. format.
1591 data test; 1592 to_date=23122; 1593 put to_date date9.; 1594 run; 22APR2023
Try something like this to see the impact of using different formats to display the same number.
DATA mydata4;
SET mydata3;
from_date2=from_date;
from_date3=from_date;
from_date4=from_date;
format from_date comma6. from_date2 ddmmyy10. from_date3 date9. from_date4 yymmdd10.;
run;
PS Displaying dates in either DMY or MDY order will confuse half of your audience.
22/04/2023 in "numeric" form is twenty-two divided by four divided by two thousand and twenty-three and so has nothing to with a date value.
The number in your PICTURE looks to be 23,122 (twenty-three thousand one hundred and twenty-two).
If you want that number to PRINT as 22APR2023 then just print it using the DATE9. format.
1591 data test; 1592 to_date=23122; 1593 put to_date date9.; 1594 run; 22APR2023
Try something like this to see the impact of using different formats to display the same number.
DATA mydata4;
SET mydata3;
from_date2=from_date;
from_date3=from_date;
from_date4=from_date;
format from_date comma6. from_date2 ddmmyy10. from_date3 date9. from_date4 yymmdd10.;
run;
PS Displaying dates in either DMY or MDY order will confuse half of your audience.
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!
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.