BookmarkSubscribeRSS Feed
Sandeep77
Lapis Lazuli | Level 10

I am trying to get a data from the previous table using from statement but getting error. Please suggest experts.

proc sql;
create table Test AS
Select
Account_code
From work.'foreign address'n;
quit;


proc sql;
create table Add_repcode as 
select a.*,
b.rep_code,
From Test
inner join p2scflow.debt as b on a.Account_code= b.Account_code;
quit;
Getting this error

30         proc sql;
31         create table Add_repcode as
32         select a.*,
33         b.rep_code,
34         From Test
                _________________
                79
ERROR 79-322: Expecting a FROM.

35         inner join p2scflow.debt as b on a.account_code = b.account_code ;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
36         quit;
4 REPLIES 4
Tom
Super User Tom
Super User

You have an extra comma.

Make sure that you define the aliases if you are going to use them to reference variables from specific input dataset.

 

Do not hide continuation characters at the END of the line.  Place them at the BEGINNING of the line.  It is much easier for humans to scan for them there.

proc sql;
create table Add_repcode as 
  select a.*
       , b.rep_code
  from Test as a
   inner join p2scflow.debt as b
    on a.Account_code= b.Account_code
;
quit;

 

AMSAS
SAS Super FREQ

What @Tom points out is the comma at the end of line 4 (see my comment) is the cause of your error. Delete that comma and problem solved

proc sql;
create table Add_repcode as 
select a.*,
b.rep_code, /* This comma at the end of this line is the issue */
From Test
inner join p2scflow.debt as b on a.Account_code= b.Account_code;
quit;
Sandeep77
Lapis Lazuli | Level 10

I did tried doing that but it gave me unresolved reference and few more errors.

9         proc sql;
30         create table Add_repcode as
31         select a.*,
32         b.rep_code
33         From Test
34         inner join p2scflow.debt as b on a.account_code = b.account_code ;
ERROR: Unresolved reference to table/correlation name a.
ERROR: Could not expand a.*, correlation name not found.
ERROR: The following columns were not found in the contributing tables: a.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
35         quit;
NOTE: The SAS System stopped processing this step because of errors.
PaigeMiller
Diamond | Level 26

Because you have additional errors that become prominent once the comma is removed.

 

ERROR: Unresolved reference to table/correlation name a.

You don't have a table referred to with the alias A. So you can't use

 

select a.*,

 

I believe the fix is obvious, so I leave it as a homework assignment for you.

--
Paige Miller

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!

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
  • 4 replies
  • 589 views
  • 0 likes
  • 4 in conversation