if I resolve my macro variables like this
%let YEAR=2023:
%let FRUIT=orange;
%let TOPPING= chocolate;
%let Path= "C:\Deskop\My folder\";
libname results_1 "&Path.\Data\&FRUIT.\&TOPPING\&Year."; /*this works*/
libname results_2 "&Path.&Year.\Data\&FRUIT.\&TOPPING."; /*this don't work, and I would like this one to work since it is more efficient */
The error i get is:
107 libname results_1;
NOTE: Libref OUT was successfully assigned as follows:
Engine: V9
Physical Name: ....
108 libname results_2
ERROR: Create of library results_2 failed.
ERROR: Error in the LIBNAME statement.
If directory:
"&Path.&Year.\Data\&FRUIT.\&TOPPING."
does not exist, you won't be able to assign a library.
Remember libname statement does NOT create directories, it assigns libref to existing one.
Bart
Hello @melhaf,
libname res2 "&Path.\&Year."; libname res2 "&Path.\&Year.\&FRUIT."; libname res2 "&Path.\&Year.\&FRUIT.\&TOPPING.";
@melhaf wrote:
if I resolve my macro variables like this
%let YEAR=2023: %let FRUIT=orange; %let TOPPING= chocolate; %let Path= "C:\Deskop\My folder\"; libname results_1 "&Path.\Data\&FRUIT.\&TOPPING\&Year."; /*this works*/ libname results_2 "&Path.&Year.\Data\&FRUIT.\&TOPPING."; /*this don't work, and I would like this one to work since it is more efficient */
The error i get is:
107 libname results_1;
NOTE: Libref OUT was successfully assigned as follows:
Engine: V9
Physical Name: ....
108 libname results_2
ERROR: Create of library results_2 failed.
ERROR: Error in the LIBNAME statement.How do I solve this?
I want to see your LOG where the "this works" actually assigned a library. I expect unbalanced quotes to generate an error
%let Path= "C:\Deskop\My folder\";
libname results_1 "&Path.\Data\&FRUIT.\&TOPPING\&Year.";
Would create this line of code:
libname results_1 ""C:\desktop\My Folder\"\Data\orange\chocolate\2023";
The quotes around the PATH portion of your string would almost certainly cause an error in BOTH libname statements.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: