I have date in character format and i want to convert it into date format
Ex:-
date(In character)
2003-01
2006-11
2016-02
this is year and then month
i want to convert in date format like
date(In Date format)
Jan2003
Nov-2006
Feb2016
data want;
dt="2003-01";
actual=input(dt,anydtdte.);
format actual monyy7.;
run;
You can't directly. SAS only treats full and valid dates as date values. So what you need to do is to padd out what you have with day, then apply a format which only displays MM-YYYY - even though behind the scenes the date is complete:
data want; dt="2003-01"; actual=input(cats(dt,"-01"),yymmdd10.); format actual mmyy8.; run;
hello,
data have; infile datalines; input a $7.; a=compress(a,'-'); b=input(a,yymmn6.); format b monyy7.; datalines; 2003-01 2006-11 2016-02 ;
data want;
dt="2003-01";
actual=input(dt,anydtdte.);
format actual monyy7.;
run;
This is also working for me thanks.
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.