Taking SAS programming 1(in middle of lesson 7) using SAS university edition.
In the practice problem I am working on, this code should work (I haven't included my full path for privacy reasons).
__________
libname custfm pcfiles path="&path/custfm.xls";
proc contents data=custfm._all_;
run;
data work.males;
run;
proc print data=work.males label;
run;
libname custfm clear;
____________
Problem 1) The path that should contain custfm.xls ends in the folder ecprg193, which doesn't contain that file with the info to complete the practice.
Problem 2) SAS university edition doesn't have pcfiles engine to assign a libref to an excel file, and the directions are unclear what engine I should use. I am using an imac if that is helpful.
Thanks!
Regarding #2 try either Excel or XLSX instead of PCFILES. The format is slightly different:
libname custfm excel 'path to excel file';
libname custfm xlsx 'path to excel file';
Your paths should pretty much be '/folders/myfolders/ecprgm/...' so not sure what that needs to be masked in SAS UE.
Using a Mac or PC doesn't affect any of the code or options you need to use here.
Revisit the setup instructions and see if the set up instructions reference custfm or if there are any errors when it runs that reference it.
Okay, thank you! I will stop tearing my hair out.
I would still make sure you know how to access/import an Excel file, but you can follow the tutorials on video.sas.com > How To Tutorials>Analytics U
Good Luck!
You will want to watch concatenation of strings in the macro language.
Instead of
path="&path/custfm.xls"
better would be.
path="&path./custfm.xls"
The period indicates the end of the macro variable. Often if you do not use it with other text you will get a "macro variable not found" because the macro processor will think you had a different variable in mind. Suppose that your &path variable included the / as the last character. You might have referenced:
path="&pathcustfm.xls" thinking that the / resolves. But the macro processor would be looking for a macro variable name pathcustfm.
SAS treats the characters '\' & '/' as delimiters for macro variables as well and it resolves correctly without the period.
%let path_folder = C:\_localdata\; libname test "&path_folder\temp";
The log will show both work the same:
129 %let path_folder = C:\_localdata\; 130 131 libname test "&path_folder/temp"; NOTE: Libref TEST was successfully assigned as follows: Engine: V9 Physical Name: C:\_localdata\\temp 132 %let path_folder = C:\_localdata\; 133 134 libname test "&path_folder\temp"; NOTE: Libref TEST was successfully assigned as follows: Engine: V9 Physical Name: C:\_localdata\\temp 135 libname test "&path_folder.\temp"; NOTE: Libref TEST was successfully assigned as follows: Engine: V9 Physical Name: C:\_localdata\\temp
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.