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

Hi, 

I'm new at SAS so I hope my description is accurrate. I'm using SAS Enterprise Guide 9.4. 

I'm working with databases available in a remote server, and I am trying to calculate an average on two variables. 

Here is my code: 

 

proc sql; 

create table "AVG1" as 

SELECT *, AVG(RMEANIMT+LMEANIMT) AS AVG1

FROM WORK.QUERY_FOR_APPEND_TABLE; 

QUIT; 

 

 

Here is the log: 

proc sql

CREATE TABLE "AVG 1" AS 

SELECT *, AVG(RMEANIMT+LMEANIMT) AS AVG1

FROM WORK.QUERY_FOR_APPEND_TABLE; 

 

NOTE: The query requieres remerging summary statistics back with the original data

ERROR: User does not have appropriate authorization level for library WC000001. 

 

However I don't have any library with that name. My guess is that it comes from the WORK library but I'm not sure how to reference it. 

Thank you!.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You probably need to talk to your IT area or SAS administrator. Your code doesn't have any errors so that's fine, its some other issue.

 

You can verify if the code below will also give you an error:

proc sql; 
create table average1 as 
SELECT *, AVG(RMEANIMT+LMEANIMT) AS AVG1
FROM WORK.QUERY_FOR_APPEND_TABLE; 
QUIT; 
 

View solution in original post

5 REPLIES 5
Reeza
Super User

You probably need to talk to your IT area or SAS administrator. Your code doesn't have any errors so that's fine, its some other issue.

 

You can verify if the code below will also give you an error:

proc sql; 
create table average1 as 
SELECT *, AVG(RMEANIMT+LMEANIMT) AS AVG1
FROM WORK.QUERY_FOR_APPEND_TABLE; 
QUIT; 
 
MerAgSo
Calcite | Level 5
Apparently that was the whole problem, I changed the code and it ran
perfectly. Thank you very much.
ChrisHemedinger
Community Manager

Update: Now I see, as @Astounding pointed out, the quoted table name was the cause.  This told SAS to consider the table as a file name, not a member of a SAS library, and that's where the WCnnnnn libref came from.  

The "WC000001" tells me that a preceding step used a SAS data set directly from the file system, rather than via a library that you explicitly defined.   This technique causes SAS to assign a temporary libname behind the scenes, and the name looks like "WCnnnnnn". Instead of opening/adding a sas7bdat file directly in EG, you should first use a LIBNAME statement to define a library that maps to the folder.  That step can be in code or using the Assign Library wizard in EG.

 

Then, when you run the next step in the flow, the library definition will already be in place.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Astounding
PROC Star

Why the weird data set name?  Get rid of the quotes, get rid of the space between AVG and 1, and just:

 

create table AVG1 as ...........

Reeza
Super User

If you really want table names like that you can add an N to the end, this is known as a name literal.

 

proc sql; 
create table "AVG1"n as 
SELECT *, AVG(weight) AS AVG1
FROM sashelp.class; 
QUIT; 

I don't recommend doing that though, because then you have to type more (3 extra characters) per data set name and it makes it harder to use short cut references to data sets.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 13268 views
  • 1 like
  • 4 in conversation