<?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 Macro variable remote server funnies in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414443#M101545</link>
    <description>&lt;P&gt;Hi, I am trying to run a macro, depending on the macro variable, conditionally setup a dependent macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But something went wrong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro test(sect);
rsubmit;
options compress = binary;
%if %upcase(&amp;amp;SECT) = CAT1%then %let CAT_NUM = 001; 
  %else %if %upcase(&amp;amp;SECT) = CAT2 %then   %let CAT_NUM = 002; 

%put WAR%str(NING:) now running for &amp;amp;sect.(&amp;amp;cat_num.) ;
	data test_out;
	set source (where = (category_id in ("&amp;amp;CAT_NUM")));
    run;
endrsubmit;
%mend; 

%test(CAT1);&lt;/PRE&gt;
&lt;P&gt;Somehow, the %PUT statement managed to populate the CAT_NUM as '001'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whereas in the data step, CAT_NUM macro variable failed to resolve.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested this without the rsubmit bound and it seems to work.&amp;nbsp; However, I need this to be submitted the remote server and the macro have to be define locally. How could resolve this?&lt;/P&gt;</description>
    <pubDate>Fri, 17 Nov 2017 16:03:46 GMT</pubDate>
    <dc:creator>J_CKY</dc:creator>
    <dc:date>2017-11-17T16:03:46Z</dc:date>
    <item>
      <title>Macro variable remote server funnies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414443#M101545</link>
      <description>&lt;P&gt;Hi, I am trying to run a macro, depending on the macro variable, conditionally setup a dependent macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But something went wrong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro test(sect);
rsubmit;
options compress = binary;
%if %upcase(&amp;amp;SECT) = CAT1%then %let CAT_NUM = 001; 
  %else %if %upcase(&amp;amp;SECT) = CAT2 %then   %let CAT_NUM = 002; 

%put WAR%str(NING:) now running for &amp;amp;sect.(&amp;amp;cat_num.) ;
	data test_out;
	set source (where = (category_id in ("&amp;amp;CAT_NUM")));
    run;
endrsubmit;
%mend; 

%test(CAT1);&lt;/PRE&gt;
&lt;P&gt;Somehow, the %PUT statement managed to populate the CAT_NUM as '001'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whereas in the data step, CAT_NUM macro variable failed to resolve.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested this without the rsubmit bound and it seems to work.&amp;nbsp; However, I need this to be submitted the remote server and the macro have to be define locally. How could resolve this?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 16:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414443#M101545</guid>
      <dc:creator>J_CKY</dc:creator>
      <dc:date>2017-11-17T16:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable remote server funnies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414448#M101547</link>
      <description>&lt;P&gt;Why would it work?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your macro is running on your local machine. The SAS code that it generates between the RSUBMIT/ENDRSUBMIT statements will run on the remote machine.&lt;/P&gt;
&lt;P&gt;If you want the code on the remote machine to reference a macro variable then you need to define the macro variable on the remote machine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(sect);
rsubmit;
options compress = binary;
%if %upcase(&amp;amp;SECT) = CAT1 %then %let CAT_NUM = 001; 
%else %if %upcase(&amp;amp;SECT) = CAT2 %then %let CAT_NUM = 002; 

%put WAR%str(NING:) now running for &amp;amp;sect.(&amp;amp;cat_num.) ;
%* Push macro variable to remote session ;
%syslput CAT_NUM=&amp;amp;cat_num;

data test_out;
  set source (where = (category_id in ("&amp;amp;CAT_NUM")));
run;
endrsubmit;
%mend; 

%test(CAT1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Nov 2017 16:10:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414448#M101547</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-17T16:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable remote server funnies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414459#M101549</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tried with your modified code.&amp;nbsp; Still getting the same error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I have get it to work by moving the whole %if %then %else condition, as well as the syslput, out of the REMOTE/SUBMIT bound.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(sect);
%if %upcase(&amp;amp;SECT) = CAT1 %then %let CAT_NUM = 001; 
%else %if %upcase(&amp;amp;SECT) = CAT2 %then %let CAT_NUM = 002; 
* Push macro variable to remote session ;
%syslput CAT_NUM=&amp;amp;cat_num;

rsubmit;
options compress = binary;
%put WAR%str(NING:) now running for &amp;amp;sect.(&amp;amp;cat_num.) ;
data test_out;
  set source (where = (category_id in ("&amp;amp;CAT_NUM")));
run;
endrsubmit;
%mend; 

%test(CAT1);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Nov 2017 16:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-remote-server-funnies/m-p/414459#M101549</guid>
      <dc:creator>J_CKY</dc:creator>
      <dc:date>2017-11-17T16:20:43Z</dc:date>
    </item>
  </channel>
</rss>

