<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing SAS System options within a macro which does not contain open code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561614#M157258</link>
    <description>&lt;P&gt;Oh my, this actually worked. The issue wasn't about the string inside a data step, of course... It was exactly what the NOTE says..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot Tom for your help!&lt;/P&gt;</description>
    <pubDate>Sun, 26 May 2019 05:48:25 GMT</pubDate>
    <dc:creator>bearda</dc:creator>
    <dc:date>2019-05-26T05:48:25Z</dc:date>
    <item>
      <title>Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561562#M157236</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question was badly formed and the actual problem still exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's easiest to show the issue by example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* No open code allowed in macro */
%macro wrapper;
   
    %let options = %sysfunc(getoption(option_name));
    %let rc          = %sysfunc(SETOPTION(option_name));
    
    %* ...code... ;

    %let return_value = 123;
    
    %let rc = %sysfunc(SETOPTION(&amp;amp;options));

    &amp;amp;return_value
%mend wrapper;

%wrapper;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So what I'm looking is the replacement for nonexistent SETOPTION function to set options with pure macro language. And still macro should be used like %let value = %wrapper; or %put %wrapper;. (which means there's only macro language in macro definition)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Options set inside DOSUBL does not affect options outside DOSUBL code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been struggling with this issue for a long time and finally decided to post a question about it if someone has found an answer or have circumvent the problem somehow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We often want to produce macros which can be used like this:&lt;/P&gt;&lt;P&gt;%let variables = %getvarlist(dataset = sashelp.cars);&lt;/P&gt;&lt;P&gt;i.e there is no open code inside the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are situations when SAS Programmer wants to change the system options in macro described above. Here is an example where we don't want message: "NOTE: The quoted string currently being processed has become more than 262 char....": to appear in SAS log. I'm not looking for an answer to guides macro users to set certain system options before using the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro sysopts_withing_macro;

    %local l_rc;

    %let l_rc = %sysfunc(dosubl('
        options noquotelenmax;

        data _null_;
            length long_string $6000.;
            string = "This is a long string that will be repeated. ";
            do i = 1 to 100;
                long_string = strip(long_string) || string;
            end;
            put long_string;
        run;
    '));

%mend sysopts_withing_macro;

%sysopts_withing_macro;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 06:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561562#M157236</guid>
      <dc:creator>bearda</dc:creator>
      <dc:date>2019-07-03T06:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561574#M157245</link>
      <description>&lt;P&gt;I don't understand what the question is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying your attempt to change the option inside the DOSUBL call didn't work?&lt;/P&gt;
&lt;P&gt;Please show the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you asking why does the DOSUBL call not work when I add extra single quotes before and after the code I want to run?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying the note about string too long is being triggered by the macro generating a long quoted string?&lt;/P&gt;
&lt;P&gt;Why IS the macro generating a long quoted string?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 17:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561574#M157245</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-25T17:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561576#M157246</link>
      <description>&lt;P&gt;Replace the single quotes with %NRSTR() instead.&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 17:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561576#M157246</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-25T17:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561587#M157250</link>
      <description>&lt;P&gt;I don't think there is a general solution to a way to change an option.&amp;nbsp; Your method seems sound in general.&lt;/P&gt;
&lt;P&gt;But for&amp;nbsp;this particular option SAS is constantly scanning the input to check for the dreaded unbalanced quotes.&amp;nbsp; When you compile the macro.&amp;nbsp; When it passes the string through the %SYSFUNC() function call to the DOSUBL() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So even though if you macro protect the quotes the macro quoting gets removed by the process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best solution is to re-work your code not to have long quoted strings.&amp;nbsp; For example put them into macro variables and use SYMGET() function get the value into your character variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options quotelenmax;

%macro sysopts_withing_macro;
%local l_rc string;
%let string= 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
;
%let l_rc = %sysfunc(dosubl(%nrstr(
  data _null_;
    length long_string $6000.;
    long_string = symget('string');
    put long_string=;
  run;
)));

%mend sysopts_withing_macro;
%put macro is defined;

%put before macro is called;
%sysopts_withing_macro;
%put after macro is called;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Why the heck does calling DOSUBL in this way write a bunch of blank lines to the LOG?&lt;/P&gt;
&lt;PRE&gt;185   %put before macro is called;
before macro is called























































long_string=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456
78901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890123
45678901234567890 12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


186   %sysopts_withing_macro;
187   %put after macro is called;
after macro is called
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 20:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561587#M157250</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-25T20:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561597#M157253</link>
      <description>&lt;P&gt;1. Use PROC OPTIONS to get the current status/settings of the options you want to change.&lt;/P&gt;
&lt;P&gt;2. Change/set your options in your macro&lt;/P&gt;
&lt;P&gt;3. Reset at the end to the original values to avoid messing up someone else's system.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17588"&gt;@bearda&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been struggling with this issue for a long time and finally decided to post a question about it if someone has found an answer or have circumvent the problem somehow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We often want to produce macros which can be used like this:&lt;/P&gt;
&lt;P&gt;%let variables = %getvarlist(dataset = sashelp.cars);&lt;/P&gt;
&lt;P&gt;i.e there is no open code inside the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are situations when SAS Programmer wants to change the system options in macro described above. Here is an example where we don't want message: "NOTE: The quoted string currently being processed has become more than 262 char....": to appear in SAS log. I'm not looking for an answer to guides macro users to set certain system options before using the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro sysopts_withing_macro;

    %local l_rc;

    %let l_rc = %sysfunc(dosubl('
        options noquotelenmax;

        data _null_;
            length long_string $6000.;
            string = "This is a long string that will be repeated. ";
            do i = 1 to 100;
                long_string = strip(long_string) || string;
            end;
            put long_string;
        run;
    '));

%mend sysopts_withing_macro;

%sysopts_withing_macro;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 22:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561597#M157253</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-25T22:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561613#M157257</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can play with the code I passed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;Are you saying your attempt to change the option inside the DOSUBL call didn't work?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- I'm asking whether one can change SAS system options within a macro on run time without using open code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Are you saying the note about string too long is being triggered by the macro generating a long quoted string?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- Yes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Why IS the macro generating a long quoted string?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- Not relevant ... EDIT: THIS WAS THE MOST RELEVANT THING HERE.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 May 2019 05:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561613#M157257</guid>
      <dc:creator>bearda</dc:creator>
      <dc:date>2019-05-26T05:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561614#M157258</link>
      <description>&lt;P&gt;Oh my, this actually worked. The issue wasn't about the string inside a data step, of course... It was exactly what the NOTE says..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot Tom for your help!&lt;/P&gt;</description>
      <pubDate>Sun, 26 May 2019 05:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/561614#M157258</guid>
      <dc:creator>bearda</dc:creator>
      <dc:date>2019-05-26T05:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Changing SAS System options within a macro which does not contain open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/570841#M161016</link>
      <description>&lt;P&gt;Bump&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 06:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-SAS-System-options-within-a-macro-which-does-not/m-p/570841#M161016</guid>
      <dc:creator>bearda</dc:creator>
      <dc:date>2019-07-03T06:37:06Z</dc:date>
    </item>
  </channel>
</rss>

