BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

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 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Like this?

 

data test;
    num=10122019;
    dt=input(put(num, 8.), ddmmyy8.);
    format dt ddmmyy10.;
run;
thanikondharish
Calcite | Level 5
I know this one is there any direct format like date9 ddmmyyd10
PaigeMiller
Diamond | Level 26

@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!

--
Paige Miller

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 740 views
  • 1 like
  • 4 in conversation