As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Difference between revisions of "Tips:Use the RESOLVE Function to Build a List into a Macro Variable"

From sasCommunity
Jump to: navigation, search
(tip ready)
(Scheduled July 21, 2011)
Line 40: Line 40:
<div style="float:right">Submitted By [[User:Otterm1|Otterm1]]</div>
<div style="float:right">Submitted By [[User:Otterm1|Otterm1]]</div>
[[Category:Tip Ready]]
[[Category:Tip in Use]]

Revision as of 22:08, 17 July 2011

One way to build a concatenated list and store it in a macro variable is to use the RESOLVE function with CALL SYMPUT:

%let namelist=;
data _null_;
	set sashelp.class;
	call symput('namelist', trim(resolve('&namelist'))||' '||trim(name));
%put &namelist;

NOTE: The resulting macro variable must be no longer than 64,000 characters.

This can also be done in PROC SQL:

proc sql noprint;
 select trim(name) into :namelist separated by ' ' from sashelp.class;

The data step approach may be preferred if additional logic is needed to determine or select the values to be included.

....see also

Submitted By Otterm1