BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lillymaginta
Lapis Lazuli | Level 10

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

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

Astounding
PROC Star

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;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 680 views
  • 1 like
  • 3 in conversation