data ex ;
num=10122019 ;
num1=num ;
format num1 ddmmyyd10. ;
run;
num1 variable should be ddmmyyd10 format but the above program is not working .
For 10122019(day month year) is there any format
Like this?
data test;
num=10122019;
dt=input(put(num, 8.), ddmmyy8.);
format dt ddmmyy10.;
run;
You need to change the value to a SAS date value to make a date format work, period.
@thanikondharish wrote:
data ex ;
num=10122019 ;
num1=num ;
format num1 ddmmyyd10. ;
run;
Your value of num=10122019 looks like a date to you, but SAS does not consider this a date. It does not matter that it looks like a date to you. This is the crucial point. SAS thinks that dates are integers representing the number of days since January 1, 1960, so you have to convert the value of NUM to an actual SAS date (the number of days since 1/1/1960) before any SAS date formats will work. @PeterClemmensen (and possibly others) have shown you how to do this.
@thanikondharish, could you please go back and mark the answer by @PeterClemmensen as correct? (And similarly in your other threads?) Thanks!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.