BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xenophil
Calcite | Level 5
Table A has three variable timeStamp (TS) , ID , Click with 10000 observations , table B has two var ID and category with 20 observations , B.ID is unique values of A.ID. need to add a third column 10000 observations in A, cat1 ( empty column already added ) that has B.category values where A.ID= B.ID. this code giving error. proc sql; insert into sasuser.A.cat1 select Category from sasuser.B where sasuser.A.id= sasuser.B.id; run; 22 76 ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT, HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, OUTER, UNION, ^, ^=, |, ||, ~, ~=. ERROR 76-322: Syntax error, statement will be ignored.
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

As @LinusH pointed at, what you need is:

 

proc sql; 
update sasuser.A as a
set cat1 = (select Category from sasuser.B where id=a.id);
quit;

(untested)

PG

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20
Insert is for appending data, not updating. Use UPDATE or recreate the table uaing a join (probably simpler for your situation).
Data never sleeps
PGStats
Opal | Level 21

As @LinusH pointed at, what you need is:

 

proc sql; 
update sasuser.A as a
set cat1 = (select Category from sasuser.B where id=a.id);
quit;

(untested)

PG
xenophil
Calcite | Level 5

Thanks , it worked.

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
  • 3 replies
  • 1612 views
  • 1 like
  • 3 in conversation