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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1048 views
  • 1 like
  • 3 in conversation