<?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: Macro Variable holding &amp;quot;ENDRSUBMIT;&amp;quot; returns 'Statement not valid or used out of prope in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363924#M86239</link>
    <description>&lt;P&gt;Why are you macro quoting the macro variable? Why are you including the semi-colon in the value of macro variable? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think the real logic problem is this statement in the first macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%** move _endrsubmit to server.  Needed there? ;
%syslput _endrsubmit=&amp;amp;_endrsubmit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The RSUBMIT/ENDRSUBMIT statements are run on LOCAL server to mark the block of code that is to be rsubmitted. &amp;nbsp;If you run an ENDRSUBMIT in the block of code that is running remotely it will try to end the block of code that it is submitting to some third SAS session on some other server.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2017 19:56:44 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-06-02T19:56:44Z</dc:date>
    <item>
      <title>Macro Variable holding "ENDRSUBMIT;" returns 'Statement not valid or used out of proper order'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363920#M86236</link>
      <description>&lt;P&gt;I have a need to move a series of programs from Windows to Linux and maintain them in both environments.&amp;nbsp; I want to maintain only one copy of the code however.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When running in Windows the programs use rsubmit-endrsubmit to execute code on the Linux server.&amp;nbsp; So to maintain a single copy of the code I need to have those rsubmit-endrsubmit statements execute only when the environment is Windows.&amp;nbsp; To do this I'm assigning 'rsubmit' and 'endrsubmit' as values to macro variables named &amp;amp;_rsubmit and &amp;amp;_endrsubmit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the program and log show, under Windows the &amp;amp;_rsubmit works properly but &amp;amp;_endrsubmit returns the 'Statement not valid or used out of proper order' error.&amp;nbsp; You'll see that I've used &amp;amp;syslput to move the value of &amp;amp;_endrsubmit to the server, thinking that perhaps the endrsubmit must be issued there, but the error is still returned.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the endrsubmit statement because when the code executes in Windows often there's a DATA Step or Proc SQL following the code that executes on the Linux server.&amp;nbsp; The log shows the&amp;nbsp;error is causing the second DATA Step to execute on Linux but it should execute in Windows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect the problem has&amp;nbsp;something to do with macro quoting.&amp;nbsp;&amp;nbsp;Symbolgen produces a message about quoting.&amp;nbsp; I have to use %str() to get the ; included as part of the resolved value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS 9.4 M2 on both Windows and Linux 64.&amp;nbsp; Suggestions will be appreciated.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John Bentley&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CODE--&lt;BR /&gt;&lt;BR /&gt;%put os= &amp;amp;sysscp;

%let _serverAlias=SASGRID;

%macro assignRsubEndRsub;
	%** Initialize macro variables as Global. ;
	%global _rsubmit _endrsubmit;

	%** Assign macro vars based on &amp;amp;sysscp value.;
	%if &amp;amp;sysscp=WIN %then %do;
		%let _rsubmit=%str(RSUBMIT &amp;amp;_serverAlias;);
		%let _endrsubmit=%str(ENDRSUBMIT;);

		%** move _endrsubmit to server.  Needed there? ;
		%syslput _endrsubmit=&amp;amp;_endrsubmit;
	%end;
	%else %if &amp;amp;sysscp=%str(LIN X64) %then %do;
		%let _rsubmit=%str( );
		%let _endrsubmit=%str( );
	%end;
	%else %do;
		%let _rsubmit=%str(Unsupported OS);
		%let _endrsubmit=%str(Unsupported OS);
	%end;

%mend;

%assignRsubEndRsub;

%put _rsubmit= &amp;amp;_rsubmit;
%put _endrsubmit= &amp;amp;_endrsubmit;

&amp;amp;_rsubmit;
	data _null_;
	run;
&amp;amp;_endrsubmit;

data _null_;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LOG--&lt;BR /&gt;&lt;BR /&gt;393  %put os= &amp;amp;sysscp;
SYMBOLGEN:  Macro variable SYSSCP resolves to WIN
os= WIN
394
395  %let _serverAlias=SASGRID;
396
397  %macro assignRsubEndRsub;
398     %** Initialize macro variables as Global. ;
399     %global _rsubmit _endrsubmit;
400
401     %** Assign macro vars based on &amp;amp;sysscp value.;
402     %if &amp;amp;sysscp=WIN %then %do;
403        %let _rsubmit=%str(RSUBMIT &amp;amp;_serverAlias;);
404        %let _endrsubmit=%str(ENDRSUBMIT;);
405
406        %** move _endrsubmit to server.  Needed there? ;
407        %syslput _endrsubmit=&amp;amp;_endrsubmit;
408     %end;
409     %else %if &amp;amp;sysscp=%str(LIN X64) %then %do;
410        %let _rsubmit=%str( );
411        %let _endrsubmit=%str( );
412     %end;
413     %else %do;
414        %let _rsubmit=%str(Unsupported OS);
415        %let _endrsubmit=%str(Unsupported OS);
416     %end;
417
418  %mend;
419
420  %assignRsubEndRsub;
421
422  %put _rsubmit= &amp;amp;_rsubmit;
_rsubmit= RSUBMIT SASGRID;
423  %put _endrsubmit= &amp;amp;_endrsubmit;
SYMBOLGEN:  Macro variable _ENDRSUBMIT resolves to ENDRSUBMIT;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
_endrsubmit= ENDRSUBMIT;
424
425  options symbolgen;
426
427  &amp;amp;_rsubmit;
SYMBOLGEN:  Macro variable _RSUBMIT resolves to RSUBMIT SASGRID;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
NOTE: Remote submit to SASGRID commencing.
75      data _null_;
76      run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


SYMBOLGEN:  Macro variable _ENDRSUBMIT resolves to ENDRSUBMIT;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
77   &amp;amp;_endrsubmit;
NOTE: Line generated by the macro variable "_ENDRSUBMIT".
77    ENDRSUBMIT;
      ----------
      180

ERROR 180-322: Statement is not valid or it is used out of proper order.

78
79   options nosymbolgen;
80
81   data _null_;
82   run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: Remote submit to SASGRID complete.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jun 2017 19:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363920#M86236</guid>
      <dc:creator>bentleyj1</dc:creator>
      <dc:date>2017-06-02T19:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable holding "ENDRSUBMIT;" returns 'Statement not valid or used out of prope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363924#M86239</link>
      <description>&lt;P&gt;Why are you macro quoting the macro variable? Why are you including the semi-colon in the value of macro variable? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think the real logic problem is this statement in the first macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%** move _endrsubmit to server.  Needed there? ;
%syslput _endrsubmit=&amp;amp;_endrsubmit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The RSUBMIT/ENDRSUBMIT statements are run on LOCAL server to mark the block of code that is to be rsubmitted. &amp;nbsp;If you run an ENDRSUBMIT in the block of code that is running remotely it will try to end the block of code that it is submitting to some third SAS session on some other server.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 19:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363924#M86239</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-02T19:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable holding "ENDRSUBMIT;" returns 'Statement not valid or used out of prope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363932#M86241</link>
      <description>&lt;P&gt;It is hard to fool the SAS processor into doing what you want.&lt;/P&gt;
&lt;P&gt;What I have found is that if you are running a macro locally you can conditionally generate the RSUBMIT/ENDRSUBMIT statements. &amp;nbsp;But you will see a site effect that macro variables as run locally instead of remotely. &amp;nbsp;Which might be what you want any way?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro run_both(x);
  %if "&amp;amp;x"="WIN" %then %do; rsubmit; %end;
   %put &amp;amp;=x ;
   %put &amp;amp;=mvar ;
  %if "&amp;amp;x"="WIN" %then %do; endrsubmit; %end;
%mend run_both;

signon test1 sascmd='!sascmd';
%let mvar=LOCAL;
%syslput mvar=REMOTE;

* No macro at all ;
rsubmit;
   %put &amp;amp;=mvar ;
endrsubmit;

* Macro call without rsubmit;
%run_both(xxx);
* Macro call with rsubmit;
%run_both(WIN);
signoff;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Remote signon to TEST1 complete.
3161  %let mvar=LOCAL;
3162  %syslput mvar=REMOTE;
3163
3164  * No macro at all ;
3165  rsubmit;
NOTE: Remote submit to TEST1 commencing.
1       %put &amp;amp;=mvar ;
MVAR=REMOTE
NOTE: Remote submit to TEST1 complete.
3166
3167  * Macro call without rsubmit;
3168  %run_both(xxx);
X=xxx
MVAR=LOCAL
3169  * Macro call with rsubmit;
3170  %run_both(WIN);
MPRINT(RUN_BOTH):   rsubmit
NOTE: Remote submit to TEST1 commencing.
X=WIN
MVAR=LOCAL
MPRINT(RUN_BOTH):  ; endrsubmit;
NOTE: Remote submit to TEST1 complete.
3171  signoff;
NOTE: Remote signoff from TEST1 commencing
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jun 2017 20:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/363932#M86241</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-02T20:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable holding "ENDRSUBMIT;" returns 'Statement not valid or used out of prope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/364384#M86431</link>
      <description>&lt;P&gt;Thanks for your reply Tom.&amp;nbsp; It gave me a starting point, and from it I've come up with this.&amp;nbsp; I can put the code that might execute locally into macros so that's not a problem.&amp;nbsp; But&amp;nbsp;to make modifying the programs easier&amp;nbsp;I'd like to convert the %if &amp;amp;sysscp=WIN %then %end into macro variables but can't seem to get it to work because of the special characters.&amp;nbsp; I'll tinker with the quoting functions a bit more.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen;

/*rsubmit;*/
%macro testit;
	%put &amp;amp;=sysscp;

	%if &amp;amp;sysscp=WIN %then %do; rsubmit; %end;
		data _null_;
			x=1;
		run;
	%if &amp;amp;sysscp=WIN %then %do; endrsubmit; %end;
%mend testit;

%testit;

options nosymbolgen;

data _null_;
run;
/*endrsubmit;*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 21:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-holding-quot-ENDRSUBMIT-quot-returns-Statement/m-p/364384#M86431</guid>
      <dc:creator>bentleyj1</dc:creator>
      <dc:date>2017-06-05T21:41:12Z</dc:date>
    </item>
  </channel>
</rss>

