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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.