BookmarkSubscribeRSS Feed
CathyVI
Pyrite | Level 9

Hi,

I would like to merge two data set and also create a new variable by using proc sql. This is my code but am getting the following syntax error.

 

proc sql;
create table final_table_0607 as
select * from case_07 as x left join mth_0607 as y
on x.bene_id = y.bene_id
where month_fu-(mondx1+12) as month_std;
__
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, ORDER, OUTER, UNION, ^, ^=, |, ||, ~, ~=.
 
ERROR 76-322: Syntax error, statement will be ignored.
2 REPLIES 2
Kurt_Bremser
Super User

The WHERE clause needs a valid Boolean expression.

month_fu-(mondx1+12) as month_std

is not a Boolean expression, it rather looks like a part of the SELECT clause.

Sajid01
Meteorite | Level 14

Looks like you want to create a new variable month_std. I would write the code as follows 

proc sql;
create table final_table_0607 as
select *,x.month_fu-(x.mondx1+12) as month_std
 from case_07 as x left join mth_0607 as y
on x.bene_id = y.bene_id;
quit;

I have taken x.month_fu and x.modx1 as an example assuming it comes from the first table. You can take what ever is applicable in your case (x or y).

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
  • 2 replies
  • 866 views
  • 0 likes
  • 3 in conversation