Google SAS Search

Add to Google

Wednesday, August 23, 2006

Options?

Here's something a little different. I have a colleague who asked if there was a way to save the current SAS options and then restore them somewhere in the middle of a job stream. Instead of keeping track of what linesize, pagesize, etc had been set to, he wanted to just reset everything back to some "base". I did not know a way to do that off the top of my head, but after a little poking around in the onLineDoc I thought I had found the answer:

proc optsave saves your current options to a data set or to a registry key.

proc optload loads and sets the options from a data set or registry key.

So at the beginning of your sas session you could have code like this:

proc optSave data = work.myOptions;
run;


And then anywhere in the code that you wanted to set the options back to the way they were when sas started you could run code like this:

proc optLoad data = work.myOptions;
run;


You would think that would do the trick, right?

Unfortunately it doesn't seem to work as advertised. My colleague wrote back with the following:

Try this code. I got inconsistant result:

options ls=100;
proc optsave out=work.ycOpt1;run;
%put ls is %sysfunc(getoption(LS));

options ls=120;
proc optload data=work.ycOpt1;run;
%put ls is %sysfunc(getoption(LS));


When it gets restored linesize (ls) is. . . 96!?

This is using SAS 9.13 on Windows XP. However, the exact same code works as expected under Unix and the linesize option gets correctly restored to 100.

What gives?

1 comment:

  1. that is odd, the data set ycopt1 shows linesize is 110, but the %sysfunc returns 112:

    2589 options ls=100;
    2590 proc optsave out=work.ycOpt1;run;

    NOTE: The data set WORK.YCOPT1 has 189 observations and 2 variables.
    NOTE: PROCEDURE OPTSAVE used (Total process time):
    real time 0.04 seconds
    user cpu time 0.00 seconds
    system cpu time 0.01 seconds
    Memory 68k


    2591 %put ls is %sysfunc(getoption(LS));
    ls is 100
    2592
    2593 options ls=120;
    2594 proc optload data=work.ycOpt1;run;

    NOTE: PROCEDURE OPTLOAD used (Total process time):
    real time 0:10.76
    user cpu time 0:00.48
    system cpu time 0:00.37
    Memory 46k


    2595 %put ls is %sysfunc(getoption(LS));
    ls is 112

    ReplyDelete