Hi ,
I have a variable x. It contains string like
x
02p wed ssd values having alpha numeric
people having rty ers that udf
they have edf 234 bcd fgh
I need to Create y
y
02p wed ssd
rty ers udf
edf 234 bcd fgh
I need to pull length of 3 from the given string.
Can any once help me out on this.
Thanks,
sai
How about the following?
DATA WANT;
SET HAVE;
LENGTH Y $200 DONE 3;
DO I = 1 BY 1 UNTIL (DONE);
Y1 = SCAN(X,I);
IF LENGTH(Y1) = 3 THEN Y = CATX(' ',Y,Y1);
IF Y1 = '' THEN DONE = 1;
END;
DROP Y1 DONE;
RUN;
You can also try PRX:
data x;
infile cards truncover;
input var $200.;
cards;
people having rty ers that udf 34
they have edf 234 bcd fgh t
;
data y;
set x;
new_var=prxchange('s/(\b[0-9a-zA-Z]{4,}\b)|(\b[0-9a-zA-Z]{1,2}\b)//i',-1, var);
run;
Haikuo
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Join SUGA
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.