Please can anyone guide me how to do it apart from stripging the value to ddmmmyyyy format?
I don't know if there is an informat which can read the value, but you can adapt it so ANYDTDTE can read it.
data _null_;
x='12december2015';
y=compress(x,,'d')||' '||substr(x,1,2)||', '||scan(x,-1,,'ab');
z=input(y,ANYDTDTE21.);
put z date9.;
run;
I don't know if there is an informat which can read the value, but you can adapt it so ANYDTDTE can read it.
data _null_;
x='12december2015';
y=compress(x,,'d')||' '||substr(x,1,2)||', '||scan(x,-1,,'ab');
z=input(y,ANYDTDTE21.);
put z date9.;
run;
Please can you explain 'ab' in scan function?
Hello,
you can check here the modifiers role within scan function.
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm
Another method:
data want; x='12december2016'; thedate=input(cat(substr(x,1,2),upcase(substr(x,3,3)),substr(x,11,4)),date9.); format thedate date9.; run;
Thank you for your time and answer but only problem with this is you have to change length for year extraction for diffrent month
Yes, sorry, didn't think of that, here is an update to catch this:
data want; x='12december2016'; thedate=input(cat(substr(x,1,2),upcase(substr(x,3,3)),substr(x,lengthn(x)-3,4)),date9.); format thedate date9.; run;
data _null_;
x='12december2015';
y=input(x,anydtdte32.);
put y= date9.;
run;
HI Ksharp
This one I did try but somehow gives missing value
@dpa wrote:
HI Ksharp
This one I did try but somehow gives missing value
Please show which input string results in a missing value.
data _null_;
252 x='12december2015';
253 y=input(x,anydtdte32.);
254
255 put y= date9.;
256 run;
y=.
log copy and pasted here
27 data _null_;
28 x='12december2015';
29 y=input(x,anydtdte32.);
30 put y= date9.;
31 run;
y=12DEC2015 with SAS9.4 on WINx64
y=12DEC2015 with SAS9.4 on LINx64
y=. with SAS9.3 on Z/OS
This works in 9.3:
data _null_;
X='12december2015';
Y=input(prxchange('s/(\d{2}\w{3})\w*(\d{4})/$1$2/',1,X),date9.);
put Y= date9.;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.