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

The following PROC SQL code does not work while the DATA step works.

proc sql;
  create table want as
  select *
    from sashelp.class
	where name in: ('Al','Wi');
quit;

data want;
  set sashelp.class;
  where name in: ('Al','Wi');
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @SAS_inquisitive,

 

The IN operator is working in PROC SQL, but PROC SQL does not support the colon operators for truncated string comparisons. There are equivalents to =:, <: etc. (EQT, LTT, ...), but I'm not aware of an equivalent to IN:.

View solution in original post

5 REPLIES 5
data_null__
Jade | Level 19
32         GOPTIONS ACCESSIBLE;
33         proc sql;
34           create table want as
35           select *
36             from sashelp.class
37         	where name in: ('Al','Wi');
                         _
                         22
                         200
ERROR 22-322: Syntax error, expecting one of the following: (, SELECT.  

ERROR 200-322: The symbol is not recognized and will be ignored.

Did you notice this error?

FreelanceReinh
Jade | Level 19

Hi @SAS_inquisitive,

 

The IN operator is working in PROC SQL, but PROC SQL does not support the colon operators for truncated string comparisons. There are equivalents to =:, <: etc. (EQT, LTT, ...), but I'm not aware of an equivalent to IN:.

Haikuo
Onyx | Level 15

Nope. You are correct, not for 'in'.

 

Although there are some undocumented equivalent to data step:

EQ:, GT:, LT:, GE:, LE:, NE:

 

existing as

 

EQT, GTT, LTT, GET, LET, NET

 

in Proc SQL environment.

 

 

FreelanceReinh
Jade | Level 19

You could use the WHERE= dataset option in PROC SQL and use the IN: operator there:

proc sql;
  create table want(where=(name in: ('Al','Wi'))) as
  select *
    from sashelp.class;
quit;
SAS_inquisitive
Lapis Lazuli | Level 10

Perfect. It works.  Thanks !

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 3819 views
  • 4 likes
  • 4 in conversation