Hi all,
I have the following statement:
data a (drop=i); set b; array x{*} dx:; r=1=0;
do i=1 to dim(x); if susbtrn(x{i},1,3) in ('210','220') then do; r=1;
leave;
end;
end;
run;
my question if I want to include another entry with a length of 4 meaning if susbtrn= '210', '220', '2320', how can I adjust the above statement to account for different the lengths?
data a (drop=i); set b; array x{*} dx:; r=1=0;
do i=1 to dim(x);
if susbtrn(x{i},1,3) in ('210','220')
or susbtrn(x{i},1,4) in ( '2320')
then do; r=1;
leave;
end;
end;
run
data a (drop=i); set b; array x{*} dx:; r=1=0;
do i=1 to dim(x);
if susbtrn(x{i},1,3) in ('210','220')
or susbtrn(x{i},1,4) in ( '2320')
then do; r=1;
leave;
end;
end;
run
I'm not sure you have the spelling right, but here's a variation that works for character strings:
if x{i} in : ('210','220','2299') then do;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.