0
votes

I'm unsure how to correct the syntax inside of my proc sql in SAS. My code goes something like the following:

proc sql;
    create table HI
    as select [columns]
from [table]
where column1 not in ('..', '..', '..') /*This has no errors*/
AND column2 in ('...', '...', '...') /*This has no errors*/
AND column3 in (('...','...','...',.......)
    or column3 like ('J%')) /*This AND statement gives the errors*/

The first error is that it is expecting a SELECT and has underlined the first '...' for the condition on column3. (Error 79-322)

The next error is at the end of the conditions on column 3 before the OR statement. It says that it is expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,..... (Error 22-322)

Then there are two more errors that say the symbol is not recognized and another that the statement will be ignored. --but I figure these will correct if the others are corrected.

Any help is appreciated :)

3

3 Answers

2
votes

change last 2 lines as

 AND (column3 in ('...','...','...',.......)
or column3 like ('J%')) 

/* example*/
 proc sql;
create table HI
as select *
 from sashelp.cars
 where make not in ('Acura', 'Audi') /*This has no errors*/
  AND Type in ('SEDAN', "Sports") /*This has no errors*/
 AND (Origin in ('Asia','Europe')
  or Origin like ('U%')) ;
0
votes

Use find operator

AND column3 in (('...','...','...',.......)
or (find(column3,J)>0 and substr(column3,1,1)='J') /*Making sure first char is J*/
0
votes

Add a pair parentheses for column3 condition like this

AND (column3 in (('...','...','...',.......)
or column3 like ('J%'))) /*This AND statement gives the errors*/