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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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