Example 14: Create a Quoted List Separated by
Spaces
Details
This example illustrates how to create a space-separated list that is quoted using the
techniques of CALL SYMPUTX and CALL EXECUTE routines.
Program
data one;
input empl $;
datalines;
12345
67890
45678
;
%let list=;
data _null_;
set one;
call symputx('mac',quote(strip(empl)));
call execute('%let list=&list &mac');
run;
%put &=list;
Program Description
Create a data set named One.
data one;
input empl $;
datalines;
12345
67890
45678
;
Use the %LET statement to create a macro variable called &LIST and set it to a null
value.
%let list=;
data _null_;
Begin a DATA step and set the data set containing the values to be placed in the list. Use
CALL SYMPUTX to create a macro variable called &MAC. The QUOTE function is
used so that the returned value from the data set variable EMPL is quoted. The STRIP
function is used to remove any leading or trailing blanks within the quoted value. This
value is placed inside the macro variable &MAC. CALL EXECUTE is used to build a
%LET statement for each observation in the data set. This will append each value of
&MAC onto the previous value of &LIST (&LIST is null the first time).
Example 14: Create a Quoted List Separated by Spaces 473
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset