As the first step in the decommissioning of sasCommunity.org 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 "Tip of the Day:December 29"

From sasCommunity
Jump to: navigation, search
m (Scheduled ODS Tip Sheets)
(Scheduled Execution Time Macro Variable Resolution)
 
Line 5: Line 5:
 
sasCommunity Tip of the Day
 
sasCommunity Tip of the Day
 
</h1><div style="padding:10px;">
 
</h1><div style="padding:10px;">
{{Tips:ODS Tip Sheets}}
+
{{Tips:Execution Time Macro Variable Resolution}}
 
<div style="width:100%"><hr></div>
 
<div style="width:100%"><hr></div>
Feel free to [[Tips Talk:ODS Tip Sheets|comment]] on this tip.
+
Feel free to [[Tips Talk:Execution Time Macro Variable Resolution|comment]] on this tip.
 
</div>
 
</div>
 
</td></tr>
 
</td></tr>

Latest revision as of 00:52, 27 December 2014

sasCommunity Tip of the Day

Usually, when macro variables are resolved in a DATA step, doing so before the compilation phase does just what you want. However sometimes you can improve performance and shorten your code structures by resolving the macro variables during the execution phase.

The incoming data set has a variable CODE which takes on the values 1, 2, and 3. A weight adjustment factor has been stored in corresponding macro variables &CORR1, &CORR2, and &CORR3. In this DATA step, the macro variables are resolved before the compilation phase.

Through the use of the executable SYMGET function, we can retrieve a macro variable based on the value of a variable on the PDV. Here the variable CODE, which is on the incoming data set, is used to form the name of the macro variable to be retrieved by SYMGET.

%let corr1 = 1.1;
%let corr2 = 2.2;
%let corr3 = 3.3;
data corrwt;
   set weights;
   if code=1 then wt = wt*&corr1;
   else if code=2 then wt = wt*&corr2;
   else if code=3 then wt = wt*&corr3;
   run;
%let corr1 = 1.1;
%let corr2 = 2.2;
%let corr3 = 3.3;
data corrwt;
   set weights;
   wt = wt*symget(catt('corr',code));
   run;


Submitted By Art Carpenter (talk)



Feel free to comment on this tip.


Prior tip - Next tip - Random Tip

Submit a Tip