BookmarkSubscribeRSS Feed
alilacey0
Fluorite | Level 6

I am trying to find any row that contains a number from 2-9 in it in proc sql. I have tried multiple solutions and have researched other peoples questions on this topic and nothing seems to produce a result for me. Here is what I have tried:

 

proc sql;
select *
from one
where Make like '%[2-9]%';
run;

 

proc sql;
select *
from one
where Make like '[2-9]';
run;

 

proc sql;
select *
from one
where Make like '.[2-9].';
run;

 

proc sql;
select *
from one
where Make contains '[2-9]';
run;

 

proc sql;
select *
from one
where Make like '.*[2-9]*.';
run;

 

None of these seem to produce any results for me. Thank you in advance for any help.

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Show test data, in the form of a datastep.  As such I can only guess, but maybe think about it differently or:

where 2 <= make <= 9;

 

FreelanceReinh
Jade | Level 19

Try this:

where findc(make,'23456789');

This WHERE condition is met if the value of (character) variable MAKE contains at least one of the digits 2, 3, ..., 9.

 

(And don't forget that PROC SQL steps end with a QUIT statement, not RUN.)

ballardw
Super User

You might show a few explicit values of  the variable MAKe, indicate if the variable is character or numeric, and show which ones of your examples you want to treat as 'in range' (and include some examples that are not in range)

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 851 views
  • 0 likes
  • 4 in conversation