BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SaschaD
Obsidian | Level 7

Hello,

 

I try to insert in TableB all items from TableA which are not appear in TableB.

 

PROC SQL;
	INSERT INTO SERVER.TABLEB (GRVID)
	SELECT VTGONR
	FROM SERVER.TABLEA
	WHERE not in (SELECT GRVID FROM SERVER.TABLEB); 
QUIT;

But if I run this code, I get Always an error.

The field GRVID is underlined and I get following error text:

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, ?, AND,
BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||,
~, ~=.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

If I run the code without the WHERE clause it works, but if I add the WHERE clause I get the error.

 

Thanks,

Sascha

1 ACCEPTED SOLUTION

Accepted Solutions
Sathish_jammy
Lapis Lazuli | Level 10
PROC SQL;
	INSERT INTO SERVER.TABLEB (GRVID)
	SELECT VTGONR
	FROM SERVER.TABLEA
	WHERE VTGONR not in (SELECT GRVID FROM SERVER.TABLEB); 
QUIT;

 Mention the Key variable before NOT IN

View solution in original post

1 REPLY 1
Sathish_jammy
Lapis Lazuli | Level 10
PROC SQL;
	INSERT INTO SERVER.TABLEB (GRVID)
	SELECT VTGONR
	FROM SERVER.TABLEA
	WHERE VTGONR not in (SELECT GRVID FROM SERVER.TABLEB); 
QUIT;

 Mention the Key variable before NOT IN

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
  • 1 reply
  • 798 views
  • 0 likes
  • 2 in conversation