SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 24841: Executing Your Stored Formats at Start-Up

DetailsAboutRate It
When I have formats in a permanent catalog, or seek to add the formats of an application I am starting, I issue a statement like:
         option %addoptn( fmtsearch, sasuser ) ;

The same macro allows me to add a fileref to sasautos like

         filename mymacs 'h:\sas\myMacros' ;
         option %addoptn( sasautos, mymacs );

The macro has a parameter to place the new path in front or at the back of the existing option, defaulting to at=front.

The macro uses the getoption() function to retrieve the existing SAS option value, inside %sysfunc() so that it can execute in the macro environment. The only complicated thing about the macro, is that these system options may be in parenthesis, which must be removed before prefixing or suffixing with the additional path:

%macro addoptn( op, addn, at=front );
   %local mainpart rebuild ;
   %let mainpart = %sysfunc( compress( %sysfunc( getoption( &op ) ), () )) ;
                          /* compress to remove the (parenthesis) */
   %if &at= front %then
      %do;
         %let rebuild = &addn &mainpart ;
      %end;
   %else
      %do;
         %let rebuild =       &mainpart &addn ;
      %end;
 &op = ( &rebuild )
%mend  addoptn;
/******** demo
   option %addoptn( sasautos, mymacs )
          %addoptn( fmtsearch, oldbits, at=end ) ; *******/

This Quick Tip was submitted by Peter Crawford, an independent consultant and SAS partner in the UK.

You can contact Peter at peter.crawford@blueyonder.co.uk.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.