To prevent from editing SAS options

Accepted Solution Solved
Reply
Contributor
Posts: 61
Accepted Solution

To prevent from editing SAS options

Hi, This is my requirment, we are working on set of macros which are interrelated to each other, and the initial program that executes sets the system options as required. Once done this will be deployed to the user end. The user will be able to execute his own codes after initiating the session. To give the expected output in particular format, we need to make sure that the sas options are not changed during execution. Is there any way that we can lock the options been set after the execution of the initial program. Kindly advice. Thanks, Mooovendhan Devaraj

Accepted Solutions
Solution
‎06-30-2016 03:36 PM
Respected Advisor
Posts: 3,777

Re: To prevent from editing SAS options

Look into using PROC OPTSAVE in the initial macro and then let the the other macro(s) use OPTSAVE/PROC COMPARE to determine if there have been changes and reset them using OPTLOAD.

 

I use this technique in macro where I want to preserve and reset the users options after I change them in my macro.

 

   /*------------------------------------------------------------------------*
    | Reset system options changed by the macro.
    *------------------------------------------------------------------------*/
   proc optsave out=&m._optsave2;
      run;
   proc compare noprint base=&m._optsave1 compare=&m._optsave2 outbase outnoequal out=&m._optchange;
      run;
   data _null_;
      set &m._optchange;
      if _N_ eq 1 then put 'NOTE: The following options are being reset to previous values.';
      put 'NOTE- ' (OPTNAME OPTVALUE)(=);
      run;
   proc optload data=&m._optchange(keep=optname optvalue);
      run;

 

View solution in original post


All Replies
Super User
Posts: 5,081

Re: To prevent from editing SAS options

Probably not.  Another approach would be to capture the original option settings, and then restore options to those original values as your macro begins to execute.

Super User
Posts: 10,497

Re: To prevent from editing SAS options

If a Macro or program requires specific options I would recommend making sure that they are available when needed. You can use the OPTSAVE procedure to capture a users options and OPTLOAD to set the options you need and then restore the users options after the options are no longer needed.

 

Since the OPTLOAD uses a dataset then your implementation of the preferred options would be calling the procedure with a dataset containing the options needed.

 

So your macros could contain code like:

 

Proc optsave out=lib.useropts;run;

Proc optload data=permlib.macroopts;run;

<other macro code>

Proc optload data=lib.useropts;run;

 

 

 

Solution
‎06-30-2016 03:36 PM
Respected Advisor
Posts: 3,777

Re: To prevent from editing SAS options

Look into using PROC OPTSAVE in the initial macro and then let the the other macro(s) use OPTSAVE/PROC COMPARE to determine if there have been changes and reset them using OPTLOAD.

 

I use this technique in macro where I want to preserve and reset the users options after I change them in my macro.

 

   /*------------------------------------------------------------------------*
    | Reset system options changed by the macro.
    *------------------------------------------------------------------------*/
   proc optsave out=&m._optsave2;
      run;
   proc compare noprint base=&m._optsave1 compare=&m._optsave2 outbase outnoequal out=&m._optchange;
      run;
   data _null_;
      set &m._optchange;
      if _N_ eq 1 then put 'NOTE: The following options are being reset to previous values.';
      put 'NOTE- ' (OPTNAME OPTVALUE)(=);
      run;
   proc optload data=&m._optchange(keep=optname optvalue);
      run;

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 264 views
  • 2 likes
  • 4 in conversation