BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

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
Fluorite | Level 6
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1066 views
  • 1 like
  • 4 in conversation