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
Then do
data test;
mydate="25.3.2016";
mydatenum=input(mydate, ddmmyy10.);
format mydatenum ddmmyyp10.;
run;
Use ddmmyy10. informat like this
data test;
mydate="25.3.2016";
mydatenum=input(mydate, ddmmyy10.);
format mydatenum ddmmyy10.;
run;
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 |
Then do
data test;
mydate="25.3.2016";
mydatenum=input(mydate, ddmmyy10.);
format mydatenum ddmmyyp10.;
run;
perfect!
Once again: read the documentation!
There are no delimiter-specific informats, you only need to use ddmmyy10.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.