BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Babloo
Rhodochrosite | Level 12

Could you help me convert character date to numeric date? Code which I tried is

 

data dates;
	length mydate $ 10;
	input mydate $;
	datalines;
25.3.2016
;
run;

data dat (drop=mydate);
	set dates;
	mydates=input(mydate,ddmmyyp10.);
run;

Warning/Error:

 

36         	mydates=input(mydate,ddmmyyp10.);
                                 __________
                                 485
NOTE 485-185: Informat DDMMYYP was not found or could not be loaded.

37         run;

NOTE: Invalid argument to function INPUT at line 36 column 10.
mydate=25.3.2016 mydates=. _ERROR_=1 _N_=1

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Then do

 

data test;
    mydate="25.3.2016";
    mydatenum=input(mydate, ddmmyy10.);

    format mydatenum ddmmyyp10.;
run;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Use ddmmyy10. informat like this

 


data test;
    mydate="25.3.2016";
    mydatenum=input(mydate, ddmmyy10.);

    format mydatenum ddmmyy10.;
run;
Babloo
Rhodochrosite | Level 12

I want date to displayed as 25.3.2016 and it should be numeric. But your code yields as 25/03/2016

 

Obs mydate mydatenum
1 25.3.2016 25/03/2016
PeterClemmensen
Tourmaline | Level 20

Then do

 

data test;
    mydate="25.3.2016";
    mydatenum=input(mydate, ddmmyy10.);

    format mydatenum ddmmyyp10.;
run;
Babloo
Rhodochrosite | Level 12

perfect!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 2223 views
  • 3 likes
  • 3 in conversation