data test2;
input type$ desp$;
datalines;
Dj dfg
jD dfg
DD dfg
dd dfg
J jam
v var
g gas
A apple
C cat
h hat
Aj rrr
Aa fff
1 222
2 333
;
data set1 set2 set3 set4 set5;
set test2;
if anydigit(type)>0 and anyalpha(type)=0 then output set1 ;
else if anyalpha(type)>0 and anydigit(type)=0 and anylower(type)=0 then output set2;
else if anyalpha(type)>0 and anydigit(type)=0 and anyupper(type)=0 then output set3;
if anyupper(first(type))>0 and anylower(type)>0 then output set4;
else if anylower(first(type))>0 and anyupper(type)>0 then output set5;
run;
data test2;
input type$ desp$;
datalines;
Dj dfg
jD dfg
DD dfg
dd dfg
J jam
v var
g gas
A apple
C cat
h hat
Aj rrr
Aa fff
1 222
2 333
;
data set1 set2 set3 set4 set5;
set test2;
if anydigit(type)>0 and anyalpha(type)=0 then output set1 ;
else if anyalpha(type)>0 and anydigit(type)=0 and anylower(type)=0 then output set2;
else if anyalpha(type)>0 and anydigit(type)=0 and anyupper(type)=0 then output set3;
if anyupper(first(type))>0 and anylower(type)>0 then output set4;
else if anylower(first(type))>0 and anyupper(type)>0 then output set5;
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.