Default value to macro variable

This post was kindly contributed by AFHood Analytics Group - Blogs » SAS - go there to comment and to read the full post.

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

This post was kindly contributed by AFHood Analytics Group - Blogs » SAS - go there to comment and to read the full post.