Hi,
My input data 2016- Jan (Charactor) I need output only month like 01(Numaric) in DI studio.
Ex: 2016- Jan -------> 01
2016- Feb-------->02
Please help me on my request.
data want;
input date_char $;
date = input(scan(date_char,2,'-')!!scan(date_char,1,'-'),anydtdte8.);
format date date9.;
month = month(date);
cards;
2016-Jan
;
run;
do this in User Written Code
Use the input() function, together with an appropriate date informat (see the Base SAS documentation).
Yes, I have used Input() function but I couldn't able to get exact informat, please help me on informat.
What have you tried?
And talking about "exact". Thre's a space between the hyphen and the month name. You need to get rid of that first (compress()).
Their is no space between hypen and month (2016-Jan). I tried most of informats.
data want;
input date_char $;
date = input(scan(date_char,2,'-')!!scan(date_char,1,'-'),anydtdte8.);
format date date9.;
month = month(date);
cards;
2016-Jan
;
run;
do this in User Written Code
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.