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

Hello Everyone,

 

I used the following code more than 1000 times to merge and the code never lets me down. However, now I am having a weird error sign which I can no way solve. 

 

My original code is as follows:


proc sql;
create table C1 as
select a.*, b.*
from connection a
LEFT JOIN F1 b on a.ISIN = b.ISIN and a.year=b.fyear;
quit;

 

I get the following log report:

Capture.PNG

 

Could you please help me in figuring out the problem? I appreciate your help.


 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

CONNECTION is a special word in SQL that has a special meaning, and it cannot be the name of a SAS data set.


That's why the error message say it is expecting TO, you have to specify a connection TO a database.

--
Paige Miller

View solution in original post

5 REPLIES 5
Onizuka
Pyrite | Level 9

I think (i'm not sure) that you can't say a.* AND b.*

 

Try may be,

 

proc sql;
create table C1 as
select *
from connection a, F1 b
where a.ISIN = b.ISIN
and a.year = b.year ;
quit ;

 

I don't have test this but may be it works to :

proc sql;
create table C1 as
select *
from connection a
LEFT JOIN F1 b on a.ISIN = b.ISIN and a.year=b.fyear ;
quit;
PaigeMiller
Diamond | Level 26

CONNECTION is a special word in SQL that has a special meaning, and it cannot be the name of a SAS data set.


That's why the error message say it is expecting TO, you have to specify a connection TO a database.

--
Paige Miller
Onizuka
Pyrite | Level 9

@PaigeMiller wrote:

CONNECTION is a special word in SQL that has a special meaning, and it cannot be the name of a SAS data set.


That's why the error message say it is expecting TO, you have to specify a connection TO a database.


I didn't know it, thanks for the learn

nazmul
Quartz | Level 8
Thank you for the solution. It has been a great help and great learning experience
Tom
Super User Tom
Super User

It is getting confused because of the CONNECTION TO keyword.

Just use a two level name

from work.connection a

Or a name literal

from 'connection'n a

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1516 views
  • 9 likes
  • 4 in conversation