BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
heyyou1
Fluorite | Level 6

I have two tables and I want to join them together.

 

The columns of table one are 

  • name,
  • age,
  • birthday.

 

The columns of table two are

  • name,
  • salary.

 

How do i merge the data from table 2 into table 1 where the names are the same?

 

proc sql;
CREATE TABLE all_data AS
  SELECT a.*, b.* FROM
  table1 a full join table2 b
  on a.name == b.name
;
quit;

However, I get this error.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.
How do I do this?
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Show the full log - where SAS indicates the error is informative.
No double == sign is one difference. I make the reverse mistake constantly in R 🙂

View solution in original post

3 REPLIES 3
Reeza
Super User
Show the full log - where SAS indicates the error is informative.
No double == sign is one difference. I make the reverse mistake constantly in R 🙂
Reeza
Super User
Note that SAS also supports the Natural Join which is useful.
Tom
Super User Tom
Super User

SAS will SHOW YOU where the mistake is.

70    proc sql;
71    CREATE TABLE all_data AS
72      SELECT a.*, b.* FROM
73      table1 a full join table2 b
74      on a.name == b.name
                   -
                   22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
              a missing value, BTRIM, INPUT, PUT, SUBSTRING, USER.

75    ;
76    quit;

You have typed the equality operator symbol twice. Remove one of the equal signs,  a.name=b.name, or just use the  mnemonic equivalent, a.name eq b.name.

https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p00iah2thp63bmn1lt20esag14lh.htm

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1443 views
  • 2 likes
  • 3 in conversation