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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 821 views
  • 0 likes
  • 2 in conversation