BookmarkSubscribeRSS Feed
lemon1
Calcite | Level 5

I am trying to access data from a sas7bdat file to do some analysis on it.  This is the data file:  https://github.com/JackStat/6003Data/blob/master/detroit.sas7bdat

 

I have searched this board for other .sas7bdat file questions and tried to copy their code, but it does not work for me.

 

Here is the code I have:

 

libname detData "\\csbs-cfs1.csbs.utah.edu\home_i\u1052325\Downloads\detroit.sas7bdat";
data inventory;
set detData.inventory;
run;

 

The log says this:

 

134 libname detData "\\csbs-cfs1.csbs.utah.edu\home_i\u1052325\Downloads\detroit.sas7bdat";
ERROR: Library DETDATA is not in a valid format for access method RANDOM.
ERROR: Error in the LIBNAME statement.
135 data inventory;
136 set detData.inventory;
ERROR: Libref DETDATA is not assigned.
137 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.INVENTORY may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.INVENTORY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

2 REPLIES 2
Kurt_Bremser
Super User

You do not import a .sas7bdat file, as it already is a SAS dataset. You only need to define a libname to the directory where the file is located in order to access it.

Astounding
PROC Star

The LIBNAME statement should reference a folder, not a file.  Your LIBNAME statement provides too much information:

 

libname detData "\\csbs-cfs1.csbs.utah.edu\home_i\u1052325\Downloads\detroit.sas7bdat";

 

Instead, cut it down to the path to the folder that holds the data:

 

libname detData "\\csbs-cfs1.csbs.utah.edu\home_i\u1052325\Downloads";

 

After that,  you would refer to the SAS data set as:

 

detData.detroit

 

So it's a two-part name, that references both the LIBNAME and the name of the .sas7bdat file.  In context, perhaps:

 

data inventory;

set detData.detroit;

run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 2830 views
  • 3 likes
  • 3 in conversation