I got this question on practise exams for certification, i set dataset (&library) without double quotation it didnt work for me, when i used "&library" i could create the dataset.
But answer i got in SAS site is - &library without double quotes
Complete the code below to reference a data set named data_in that is contained in the library cert. You must use the macro variable defined in the program in place of the library name.
%let library = cert.data_in; libname cert "C:\workshop\cert";
data work.data_out; set Answer; run;
@vidyapedii wrote:
Hi, Thankyou for the response,
%let library= /home/vidyapedii0/CERT/INPUT/input04;
I created macro named "library" to reference the "input04" dataset in Cert library, i used "&library" in set statement to create another dataset.
which is the correct way to use macro var library with quotes ( ex-"&library") or without quotes (ex - &library)
i got this question in practise exam, answer they have mentioned is without quotes(&library), but i couldn't create the dataset when i used macro variable without quotes (&library)
%let library=/home/vidyapedii0/CERT/INPUT/input04;data let;set "&library";run;
You created the macro variable LIBRARY to point to a FILE that has the dataset INPUT04. You made no use of a LIBRARY (or more exactly a LIBREF) named CERT. When you reference a dataset by the filename you need to enclose the values in quote (whether or not you use any macro variable).
These example SET statements all reference the same file (and so the same dataset).
set '/home/vidyapedii0/CERT/INPUT/input04';
set "/home/vidyapedii0/CERT/INPUT/input04";
set "/home/vidyapedii0/CERT/INPUT/input04.sas7bdat";
%let filename = '/home/vidyapedii0/CERT/INPUT/input04';
set &filename;
%let filename = /home/vidyapedii0/CERT/INPUT/input04;
set "&filename";
If you use a LIBNAME statement to define a libref that defines a specific library then to reference the members of that library you use a two level name without any quotes. Whether or not you use a macro varaible.
libname cert '/home/vidyapedii0/CERT/INPUT/';
set cert.input04;
%let dataset_name = cert.input04;
set &dataset_name;
%let member_name = input04 ;
set cert.&member_name;
i set dataset (&library) without double quotation it didnt work for me
Can you show us your log? It should work without the quotes:
data work.data_out;
set &library;
run;
Why do you need to change the macro variable definition from what's been given? It is given as cert.data_in but you are changing to the physical path, which won't work with the set statement without the quotes! Try it the way I suggested in my previous post.
You can reference a SAS dataset in two ways:
The second method is preferred; first assign the libname, then use the libname.dataset in the SET statement:
libname input "/home/vidyapedii0/CERT/INPUT";
data let;
set input.input04;
You can see that this SET statement is easier to read than one with the full path in quotes.
It is hard to tell from your question but I think the purpose of the question was to get you to say want text should replace the string Answer in this code:
libname cert "C:\workshop\cert";
data work.data_out;
set Answer;
run;
There is no need to create or reference a macro variable LIBRARY. Instead you want to reference the libref CERT that the code created in the LIBNAME statement.
libname cert "C:\workshop\cert";
data work.data_out;
set cert.data_in;
run;
Hi, Thankyou for the response,
%let library= /home/vidyapedii0/CERT/INPUT/input04;
I created macro named "library" to reference the "input04" dataset in Cert library, i used "&library" in set statement to create another dataset.
which is the correct way to use macro var library with quotes ( ex-"&library") or without quotes (ex - &library)
i got this question in practise exam, answer they have mentioned is without quotes(&library), but i couldn't create the dataset when i used macro variable without quotes (&library)
@vidyapedii wrote:
Hi, Thankyou for the response,
%let library= /home/vidyapedii0/CERT/INPUT/input04;
I created macro named "library" to reference the "input04" dataset in Cert library, i used "&library" in set statement to create another dataset.
which is the correct way to use macro var library with quotes ( ex-"&library") or without quotes (ex - &library)
i got this question in practise exam, answer they have mentioned is without quotes(&library), but i couldn't create the dataset when i used macro variable without quotes (&library)
%let library=/home/vidyapedii0/CERT/INPUT/input04;data let;set "&library";run;
You created the macro variable LIBRARY to point to a FILE that has the dataset INPUT04. You made no use of a LIBRARY (or more exactly a LIBREF) named CERT. When you reference a dataset by the filename you need to enclose the values in quote (whether or not you use any macro variable).
These example SET statements all reference the same file (and so the same dataset).
set '/home/vidyapedii0/CERT/INPUT/input04';
set "/home/vidyapedii0/CERT/INPUT/input04";
set "/home/vidyapedii0/CERT/INPUT/input04.sas7bdat";
%let filename = '/home/vidyapedii0/CERT/INPUT/input04';
set &filename;
%let filename = /home/vidyapedii0/CERT/INPUT/input04;
set "&filename";
If you use a LIBNAME statement to define a libref that defines a specific library then to reference the members of that library you use a two level name without any quotes. Whether or not you use a macro varaible.
libname cert '/home/vidyapedii0/CERT/INPUT/';
set cert.input04;
%let dataset_name = cert.input04;
set &dataset_name;
%let member_name = input04 ;
set cert.&member_name;
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.