DATA Step, Macro, Functions and more

Proc sql

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Proc sql

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.

Accepted Solutions
Solution
‎10-19-2015 02:04 AM
Respected Advisor
Posts: 4,644

Re: Proc sql

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


All Replies
Super User
Posts: 5,256

Re: Proc sql

Insert is for appending data, not updating. Use UPDATE or recreate the table uaing a join (probably simpler for your situation).
Data never sleeps
Solution
‎10-19-2015 02:04 AM
Respected Advisor
Posts: 4,644

Re: Proc sql

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
New Contributor
Posts: 2

Re: Proc sql

Thanks , it worked.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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