BookmarkSubscribeRSS Feed
Tjs
Fluorite | Level 6 Tjs
Fluorite | Level 6

IN SAS Studio Lesson 2 Activity- Create PROC CONTENTS

 

I check the location  for the storm_summary.sas7bdat in SAS Studio GUI and Windows Explorer location.

In SAS Studio it's  /folders/myfolders/EPG194/data

In Windows it's  C:/SASUniversityEdition/myfolder/EPG194/data

 

 

Using either or i get an error that the file path does not exist

proc contents data="C:/SASUnviersityEdition/myfolder/EPG194/data/storm_summary.sas7bdat";
run;


proc contents data"folders/myfolders/EPG194/data/storm_summary.sas7ddat";
run;
13 REPLIES 13
ballardw
Super User
proc contents data= libname.storm_summary;
run;

is the preferred way to use SAS data sets. Create a library reference that points to the storage location using a LIBNAME statement.

Something like

libname mylib "/folders/myfolders/EPG194/data";
proc contents data=mylib.storm_summary;
run;

 

Or use a complete path:

proc contents data = "/folders/myfolders/EPG194/data/storm_summary.sas7ddat";
run;

 

Tjs
Fluorite | Level 6 Tjs
Fluorite | Level 6
Thank you! I used the full path and it worked
Tom
Super User Tom
Super User

If your path does not start with / then it is a RELATIVE path and not an ABSOLUTE path.

That will not work in SAS UE since the current directory is NOT the root node.

Cynthia_sas
SAS Super FREQ

Hi:
The reason the first data=option did not work was that you cannot use a C: drive location with SAS University Edition.

The reason that the second data= option did not work was that you left the = sign out of the option and you also mis-spelled the location value.

For SAS University Edition, your main folder is
/folders
(not a Windows drive location)

and your shared folder location is /myfolders
so, the correct top level full path is (with a leading slash):

/folders/myfolders

Then, if your /EPG194 folders are UNDER that path, then the full and correct location would be (including slashes):
data="/folders/myfolders/EPG194/data/storm_summary.sas7bdat";

Other commenters are correct that the LIBNAME method is a more efficient way to reference SAS data sets. However the purpose of this activity in Programming 1 is to show that it is possible to use a physical location reference in SAS code. However, using a long path name can get cumbersome and after we show you that this technique will work, we then show the SAS syntax for LIBNAME usage.

 
Cynthia

Tjs
Fluorite | Level 6 Tjs
Fluorite | Level 6

Problem resolved.  Thanks!

andreas_lds
Jade | Level 19

Please mark a message as solution.

qxpham
Calcite | Level 5

I'm new to SAS and using SAS Studio. I tried all these methods but it did not work. I finally right-clicked on data and choose properties to see its full path which is "/home/u36524443/EPG194/data" and used it instead. It run perfectly:

 

 

proc contents data="/home/u36524443/EPG194/data/storm_summary.sas7bdat";
run;

Cynthia_sas
SAS Super FREQ

Hi:

  You are using SAS OnDemand for Academics. The previous poster was using SAS University Edition in a Virtual Machine. For your path, and the exercise you're on, your "high Level" path is:

/home/<youruserid>/EPG194/data

 

and then all the data sets and XLSX and other files used in class are in that location.

 

  After you do this practice using the fully qualified path for the storm_summary we're next going to show you the LIBNAME statement, which is a simpler way of accessing SAS datasets instead of using the fully qualified path. Instead of THIS:

proc contents data="/home/<youruserID>/EPG194/data/storm_summary.sas7bdat";
run;

 

The next thing you'll learn is how to do THIS:

** 1) point to high level location and give it an "alias" or library reference as a nickname;

libname PG1 "/home/<youruserID>/EPG194/data";

 

** 2) Use the nickname instead of the full path name in code;

proc contents data=pg1.storm_summary;
run;

 

Have fun with the class.

Cynthia

 

Fanzeng
Calcite | Level 5

thank you this method really works the best! thank you 

SAS1246996
Calcite | Level 5

/*

Using SASUniversityEdition with Windows 10 Prof

for SAS Programming 1: Essentials

Lesson 2: Accessing Data

*/

 

* This works;
libname mylib "/folders/myfolders/sasuser.v94/EPG1V2/data";
proc contents data=mylib.storm_summary;
run;

 

* and this works;
proc contents
data="/folders/myfolders/sasuser.v94/EPG1V2/data/storm_summary.sas7bdat";
run;

 

* but this gets an invalid data set name error;
libname mylib "/folders/myfolders/sasuser.v94/EPG1V2/data";
proc contents data=mylib.storm_summary.sas7bdat;
run;

* I do not understand why the file extension must be entered into the second form; but cannot be entered into the third form. ;

Cynthia_sas
SAS Super FREQ
Hi:
You have 2 choices for referencing a SAS dataset:
1) your first example -- using a 2 level name that consists of LIB.DATASET where you have a LIBNAME statement that defines the library nickname or library reference as the first level of the name and then the table or dataset that you want to reference is the second level of the 2 level name. This method does NOT need a file extension.
OR
2) your second example -- a fully qualified operating system name that includes the FULL path, including the filename and file extension -- in this case sas7bdat is the file extension for Base SAS files.

However your #3 is wrong, as it attempts to mix the 2 methods. Since a LIBNAME statement such as you show will ONLY point to SAS data in a physical location, the file extension sas7bdat is not required, and, as you found out, will not work. The only files that you would see with your LIBNAME statement would be the SAS data files in that physical location. If you want to use the file extension, then you need to focus on method 2. However, the LIBNAME method is superior. We show you the physical name method by way of comparison and to show you how easy, by comparison the 2 level LIB.DATASET method is.

Cynthia
SAS1246996
Calcite | Level 5
Thank you!
If I am understanding you correctly, then the first method worked because everything in a SAS library is already a SAS data set (it is of type sas7bdat or whatever other implicit types are allowed). The third method is redundant and causes the implied name to be something like storm_summary.sas7bdat.sas7bdat, which does not exist. Is that a reasonable interpretation?
Dave (newbie)
Tom
Super User Tom
Super User

@SAS1246996 wrote:
Thank you!
If I am understanding you correctly, then the first method worked because everything in a SAS library is already a SAS data set (it is of type sas7bdat or whatever other implicit types are allowed). The third method is redundant and causes the implied name to be something like storm_summary.sas7bdat.sas7bdat, which does not exist. Is that a reasonable interpretation?
Dave (newbie)

It is not redundant, it just does not follow the syntax.  The normal syntax to reference a dataset is to use the libref and member name.  You can also just use the member name and SAS will use the default libref, which is normally WORK.  Adding a second period and another token does not follow the syntax.

 

When you reference a dataset by its physical filename you must use a quoted string that references the actual file. And on Unix you must use only lowercase letters in the member name. Note that you can leave off the extension of the filename when referencing the dataset this way and SAS will use the default extension (currently sas7bdat) when looking for or creating the file.

 

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 13 replies
  • 8551 views
  • 16 likes
  • 8 in conversation