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

ivarenho_0-1778081098011.png

I have tried using the macro and not using the macro and I'm at a loss. Screenshot 2026-05-06 112707.png

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The first ERROR message (the one in BLACK instead of RED) in your first picture is the one you need to fix.

Screenshot 2026-05-06 at 11.43.15 AM.png

 

That error means that the dataset you are trying to export does not exist.  SAS could not find a dataset named STORM_FINAL in the libref named PG1.

 

Make sure you have defined the PG1 libref. 

Make sure that the directory ("folder") that it points to contains a file named storm_final.sas7bdat.

 

View solution in original post

8 REPLIES 8
Tom
Super User Tom
Super User

The first ERROR message (the one in BLACK instead of RED) in your first picture is the one you need to fix.

Screenshot 2026-05-06 at 11.43.15 AM.png

 

That error means that the dataset you are trying to export does not exist.  SAS could not find a dataset named STORM_FINAL in the libref named PG1.

 

Make sure you have defined the PG1 libref. 

Make sure that the directory ("folder") that it points to contains a file named storm_final.sas7bdat.

 

ivarenho
Fluorite | Level 6
In the autoexec. sas file i have libname pg1 "S/workshop/EPG1V2/"; but when I tried to change it to storm_final.sas7bdat I got an error I believe.
Tom
Super User Tom
Super User

@ivarenho wrote:
In the autoexec. sas file i have libname pg1 "S/workshop/EPG1V2/"; but when I tried to change it to storm_final.sas7bdat I got an error I believe.

So that is not a valid path. 

 

If your SAS session is running on a Windows machine then you need a colon after the S drive letter.  S:/workshop/EPG1V2/

 

If your SAS session is running on a Unix machine then you need a fully qualified path. So the path needs to start with the root node.   /S/workshop/EPG1V2/

 

The path used in the LIBNAME statement needs to point to a directory ("folder") and not to a file, so storm_final.sas7bdat should not appear in the LIBNAME statement that defines the PG1 libref.

 

In the photograph you posted you can see in the SAS/Studio Files and Folders tab that there is no sas7bdat files in that EPG1V2 folder.  Perhaps you should be using the data subfolder? S:/workshop/EPG1V2/data/ Reread the instructions.

 

In SAS/Studio expand the data folder and check if the storm_final.sas7bdat file is there.  If you can find the file then right click on the folder that contains it and ask for Properties.  That should show you the exact string you need to use in the LIBNAME statement to point to that location.

 

If you cannot find the file then go back to the earlier steps that setup the files and make sure they worked.  Perhaps when you ran those steps you also had the wrong path in the LIBNAME statement and so the dataset was never created.

ivarenho
Fluorite | Level 6
Yes when i did try to run that in the past i got and still get two errors the first is library pg is not in valid format for access method random and error in lib name statement, so i would assume i need to go back and reformat the data?
Tom
Super User Tom
Super User

@ivarenho wrote:
Yes when i did try to run that in the past i got and still get two errors the first is library pg is not in valid format for access method random and error in lib name statement, so i would assume i need to go back and reformat the data?

You will need to show the log for the actual code you ran.  Instead of taking pictures of the text just copy the text from the LOG and paste it into the pop-up window you get when you click on the Insert Code icon (looks like </>).

 

Most likely a message like that would be generated if you tried to point a libref at a FILE instead of a DIRECTORY.  Here is an example using a dataset I have in my home directory on the SAS server.

 73         libname x "~/class.sas7bdat";
 ERROR: Library X is not in a valid format for access method RANDOM.
 ERROR: Error in the LIBNAME statement.
 74         libname x "~";
 NOTE: Libref X was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /home/tom.abernathy
 75         data _null_;
 76           set x.class;
 77           put (_all_) (=);
 78         run;
 
 Student Name=Alfred Sex=M Age=14 Height=69 Weight=112.5
 Student Name=Alice Sex=F Age=13 Height=56.5 Weight=84
 Student Name=Barbara Sex=F Age=13 Height=65.3 Weight=98
 Student Name=Carol Sex=F Age=14 Height=62.8 Weight=102.5
 Student Name=Henry Sex=M Age=14 Height=63.5 Weight=102.5
 Student Name=James Sex=M Age=12 Height=57.3 Weight=83
 Student Name=Jane Sex=F Age=12 Height=59.8 Weight=84.5
 Student Name=Janet Sex=F Age=15 Height=62.5 Weight=112.5
 Student Name=Jeffrey Sex=M Age=13 Height=62.5 Weight=84
 Student Name=John Sex=M Age=12 Height=59 Weight=99.5
 Student Name=Joyce Sex=F Age=11 Height=51.3 Weight=50.5
 Student Name=Judy Sex=F Age=14 Height=64.3 Weight=90
 Student Name=Louise Sex=F Age=12 Height=56.3 Weight=77
 Student Name=Mary Sex=F Age=15 Height=66.5 Weight=112
 Student Name=Philip Sex=M Age=16 Height=72 Weight=150
 Student Name=Robert Sex=M Age=12 Height=64.8 Weight=128
 Student Name=Ronald Sex=M Age=15 Height=67 Weight=133
 Student Name=Thomas Sex=M Age=11 Height=57.5 Weight=85
 Student Name=William Sex=M Age=15 Height=66.5 Weight=112
 NOTE: There were 19 observations read from the data set X.CLASS.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       

 

ivarenho
Fluorite | Level 6
 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         libname pg1 "S:/workshop/EPG1V2/data/storm_final.sas7bdat";
 ERROR: Library PG1 is not in a valid format for access method RANDOM.
 ERROR: Error in the LIBNAME statement.
 74         
 75         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

libname pg1 "S:/workshop/EPG1V2/data/storm_final.sas7bdat";
Tom
Super User Tom
Super User

Point the libref at the DIRECTORY that contains the FILE that is the SAS dataset.

libname pg1 "S:/workshop/EPG1V2/data/";
dxiao2017
Lapis Lazuli | Level 10

Hi @ivarenho , I think the reason that the file did not export successfully was: the pg1 library did not create properly, and so that SAS could not locate the dataset storm_final. To solve the problem, you need to assign the pg1 library first, and so that SAS knows where, or in which folder, to get this dataset. The code for creating pg1 library is as follows, according to your screen capture. Write this line of code and run it before you write the code for exporting data. After you run this line of code, the log message should show that the library pg1 is created successfully.

 

libname pg1 "S:/workshop/EPG1V2/data";

 

As for the error message you got, the log tells you that your libname statement did not wrote correctly (i.e., the syntax was not correct), the reason was you mistakenly included the file name (storm_final.sas7bdat) in the libname statement, and you need to delete it from your code. The pg1 library is to be assigned to a folder, not a datafile. You cannot assign a libname to a dataset, you can only assign a libname to a folder.

 

 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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
  • 8 replies
  • 650 views
  • 0 likes
  • 3 in conversation