AFHood Group Blog The thoughtless yammerings of marketing junkies..

12Oct/100

Default value to macro variable

NOTE: This is a great one we picked up from our friends over at the SAS community.

We have run across this literally hundreds of times while programming SAS macros. You need to have a default value for a variable and you don't want to write another macro to set it if it doesn't exist.

This simple fix allows you to check for a value and set a default even in open SAS code.

%global myParameter;  /* ensure it exists */
%let myParameter = %sysfunc(coalescec(&myParameter,default-value));
Pure awesomeness..
Credit goes to Don Henderson and the SAS community for this one.
 http://www.sascommunity.org/wiki/Tip_of_the_Day:October_12
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.