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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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