I'm not sure I understand your question. However, the concept you describe "moving proc contents into created Libname folder" indicates that you might not be clear that PROC CONTENTS is showing you information about either all the datasets in a SAS library (defined with a LIBNAME statement) or PROC CONTENTS is showing you information about just 1 dataset in a SAS library (defined with a LIBNAME statement). PROC CONTENTS can point to a library location, but you don't really "move" proc contents into a libname folder.
For example, in the Programming 1 class, your data (if you follow the instructions) should be in a class folder labelled EPG1V2 and then the data is in a subfolder named data. So, for example, these are various LIBNAME statements pointing to physical folder locations on different operating systems:
libname PG1 'c:\SAS_Class\EPG1V2\data';
libname PG1 '/home/u12345678/EPG1V2/data';
libname PG1 '/usr/bin/sasczz/EPG1V2/data';
libname PG1 's:\workshop\EPG1V2\data';
Then given any of those LIBNAME statements, I could do this:
proc contents data=PG1._all_ nods;
proc contents data=PG1.np_summary;
In one of the first practices in the class, we ask you to use PROC CONTENTS on the storm_summary.sas7bdat file in the class data folder because we want students to understand that they CAN use a physical folder location with PROC CONTENTS. That practice is meant to run like this:
proc contents data='<your path to main folder>/EPG1V2/data/storm_summary.sas7bdat';
So if you were running on SAS OnDemand for Academics, for example, that code, with the full file path, would be something like:
proc contents data='/home/u12345678/EPG1V2/data/storm_summary.sas7bdat';
Then later in the class, we show you how to use a LIBNAME statement to point to the data subfolder for class so that you do not have to use the full physical path in the DATA= option.
We also show you in the Programming 1 class, how to use the XLSX Libname engine to see what tables (sheets) are in an Excel workbook.
But, none of these examples would be considered moving PROC CONTENTS into a created Libname folder. So if you can provide some more background or clarify your question, then perhaps we can provide more commentary.
Thank you for your detailed response. I want PROC CONTENTS to show data in 1 folder, for example, class_birthdate.sas7bdat.
I have begun this course before and I am at module 4 out of 7, but I am now taking the SAS Programming 1 Live on Tuesdays. I know how to follow instructions and already created a folder for libname.sas and have performed many functions already using the demo, practice, and activity folders. However, I always get stuck successfully creating my own libname and PROC CONTENTS for practice to show me a dataset.
I understand that the structure of creating a libname: libname mylib (or created name) base "~EPG1V2/data/ and the dataset name.
When I try to create a name for myself as shown above, I am not successful. I can even write it the way you have it without a name or base (since base is a default).
I tried libname mylib "~EPGV12/data/class_birthdate.sas7bdat"
Proc contents data="~EPGV12/data/class_birthdate.sas7bdat"; or proc contents data=mylib.class";
I was trying to practice the exercise in class, screen shots below.
I tried it a number of ways and I keep receiving an error message. I don't know if this is clearer. I appreciate the help.
When you have data set in a library you only need the libname.datasetname to use it. No quotes. No file extension. Just the library and set name.
If you have submitted multiple statements like
Proc contents data="mylib.class;
then you have created nested errors because the " needs to be closed. I would recommend: 1) save your code 2) close the SAS session 3) restart SAS and bring the code back into the editor 4) make the Proc Contents look like
Proc contents data=mylib.class; run;
Large hint: Instead of making pictures of code copy the text from the editor or log. Then on the forum open a text box using the </> icon above the message window and paste the text.
Then we can copy and make suggested changes the same way. Can't do that with pictures and most of us aren't willing to retype long blocks of code.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 70 71 libname mylib "~EPG1V2/data/"; ERROR: Invalid physical name for library MYLIB. ERROR: Error in the LIBNAME statement. 72 73 proc contents data= mylib.class; ERROR: Libref MYLIB is not assigned. 74 75 run; NOTE: Statements not processed because of errors noted above. NOTE: PROCEDURE CONTENTS used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 472.56k OS Memory 30124.00k Timestamp 09/21/2022 10:12:05 PM Step Count 77 Switch Count 0 Page Faults 0 Page Reclaims 57 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 8 NOTE: The SAS System stopped processing this step because of errors. 76 77 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 88
I restarted SAS studio and this is what I get now.
The first error
71 libname mylib "~EPG1V2/data/"; ERROR: Invalid physical name for library MYLIB. ERROR: Error in the LIBNAME statement.
You have to get a location that is correct for the SAS system you are using. Generally the approach is to make sure that you have a path to a location starting with a drive designation (windows) or drive mount point. So unless ~ represents and indicator as the root of a drive location you need a better path. It may be that you haven't quite followed the set up instructions for the session.
Without the slash after the ~ the first "word" is taken as the username.
So the three equivalent methods would be:
libname PG1 '~/EPG1V2/data'; libname PG1 '/home/u12345678/EPG1V2/data'; libname PG1 '~u12345678/EPG1V2/data';
But there is no real advantage of the third method when trying reference your own files. But it would have value if you wanted to reference files in some other user's home directory (assuming that they have allowed you to see them) since then you do not need to know that /home/ is the directory used to house users home directories.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.