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;
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;
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.
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
Problem resolved. Thanks!
Please mark a message as solution.
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;
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
thank you this method really works the best! thank you
/*
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. ;
@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.
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.
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.
Ready to level-up your skills? Choose your own adventure.