Having difficulty moving data for class_birthdate.sas7bdat in the data folder to a newly created folder. I am taking the SAS programming 1 and trying to practice this function.
Sometimes I have difficulty creating a libname too. For example, I tried writing libname MYWORK "EPG1V2/data/class_birthdate.sas7bdat";
What am I doing wrong?
One way to see the names of the sheets in the XLSX file is to use the XLSX LIBNAME engine. For example, we have a multi-sheet workbook called STORM.XLSX in the EPG1V2 data folder. So with this LIBNAME XLSX (below) statement, you could run the PROC CONTENTS to see the names of all the SHEETS. And one of the sheets is named storm_2017, so this code would work to do the PROC CONTENTS and then print some rows from the storm_2017 sheet:
libname xl_storm xlsx 's:\workshop\EPG1V2\data\storm.xlsx'; /* windows */
libname xl_storm xlsx '/home/<userID>/EPG1V2/data/storm.xlsx'; /* SAS OnDemand */
proc contents data=xl_storm._all_;
proc print data=xl_storm.storm_2017 (obs=20);
libname xl_storm clear;
The other way to see the names is to open the file with Excel. However, the XLSX file won't be opened on the SAS OnDemand server because it is a Linux server and it doesn't have Excel. so the PROC CONTENTS method is the programmatic way to see the sheets in the workbook.
Whenever you get an ERROR, you should show us the log (all of the log for the PROC or DATA step that has an error, not selected parts of it, all of the log for that PROC or DATA step). Please also copy the log as text (not screen capture) and paste it into the window that appears when you click on the </> icon.
Sorry I clicked quick reply instead a full reply so I could not send a screen shoot before.
I'm taking the live programming class and these are some screen shots from that class and my SAS studio log
I was successful momentarily in my last attempt to create a library, but I wanted to try again using other instructions given.
In your first screenshot you have two of the most frequent SAS coding mistakes.
Missing semicolon and unbalanced quotes.
On line 71 you never ended the LIBNAME statement so SAS thinks that the words PROC, CONTENTS and DATA= are some type of LIBNAME options that comes after the path. (There are such things, for example you can add ACCESS=READONLY to help prevent you from modifying any of the datasets in that library).
Then in line 73 you started to put quotes around the dataset name (which is also a mistake), but you never closed the quotes. So that means that everything up to the next quote will be considered part of the quoted string being used as the value of the DATA= option.
In your next photograph you show an invalid dataset name.
The part before the period is name assigned in the LIBNAME statement, the libref. The part after period is the dataset name (the member name). Dataset names cannot contain periods (unless you set the system option VALIDMEMNAME to EXTEND, but then you would need to use a NAME LITERAL and not just the bare period you used.)
The name of the DATASET is CLASS_BIRTHDAT (dataset names are NOT case sensitive).
The name of the FILE that SAS uses to store the dataset is class_birthdat.sas7bdat (filenames on a Unix operating system ARE case sensitive and SAS datasets names never use uppercase letters on Unix).
1) A libname points to a DIRECTORY (what the SAS/Studio user interface calls a "folder"). You are attempting to point to an individual FILE.
2) You need specify the full name of the directory (also called a full path). Otherwise the operating system will consider the name as being RELATIVE to its current working directory. If you are running SAS via SAS/Studio or Enterprise Guide or some other front end tool then you will not normally have any control over what the default current directory will be. And you most likely will not have write access to create any files under that directory.
On Unix (which where SAS is running for most SAS/Studio users) a full directory name starts with the root node which is indicated by a leading slash ( / ). You can also usually start the name (path) with the ~ character and that will point to your personal home directory.
So try a path more like:
libname MYWORK "~/EPG1V2/data/";
Now if you want read or write a dataset named CLASS_BIRTHDATE from that directory you can use the two level name of:
In your SAS code.
So if you already have that class_birthdate.sas7bdat file in the data subdirectory of the EPG1V2 subdirectory of your home directory then you could check its contents by running this code:
proc contents data=mywork.class_birthdate; run;
Finally, it worked!. Thank you. I think this is also challenging for me, because there are so many detailed functions to remember like quotes, semicolons, and capitalizations, not to mention I am dyslexic.
Now is this directory stored in this new folder I created permanently?
Ok, I have another libname issue. When performing the Programming 1 Essentials: Lesson 2. I'm using p102d02 and this is the code I am running to make a folder for XLSTORM.
options validvarname=v7; libname xlstorm xlsx "s:/workshop/data/storm.xlsx"; proc contents data=xlstorm.storm_summary ; run; libname xlsx clear;
I only highlighted the first two lines as instructed and was able to successfully create the folder, but there is no storm_summary content.
When I try to run everything this is the message I receive.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 70 71 options validvarname=v7; 72 73 *Complete the LIBNAME statement; 74 libname xlstorm xlsx "s:/workshop/data/storm.xlsx"; NOTE: Libref XLSTORM was successfully assigned as follows: Engine: XLSX Physical Name: s:/workshop/data/storm.xlsx 75 76 *Complete the DATA= option to reference the STORM_SUMMARY worksheet; 77 proc contents data=xlstorm.storm_summary ; ERROR: File XLSTORM.storm_summary.DATA does not exist. 78 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 1942.53k OS Memory 30008.00k Timestamp 09/22/2022 08:48:22 PM Step Count 127 Switch Count 0 Page Faults 0 Page Reclaims 545 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. 79 80 libname xlsx clear; WARNING: Libref XLSX is not assigned. 81 82 83 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 94 User: u60771588
Your help is appreciated.
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.