<?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 Calling a macro inside SAS/CONNECT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960287#M374557</link>
    <description>&lt;P&gt;I am having trouble calling a macro inside a SAS/CONNECT subsession with input parameters that are macro variables.&amp;nbsp; I have %included the macro inside the subsession and confirm that it is being found when called.&amp;nbsp; The issue comes with my use of macro variables inside the macro call (the &amp;amp;FILEIN and &amp;amp;FILEOUT parameters).&amp;nbsp; I have created these inside the subsession and used put statements to confirm that they are resolving exactly as they should be.&amp;nbsp; However, in the %winratio macro, I get an error that "Apparent symbolic reference to FILEIN not resolved" and the macro attempts to locate the dataset work.FILEIN.&amp;nbsp; Is there a way to get this to work or am I going to have to hard code my macro calls?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro doover (REMRUN=,tm= ) ; 
    %syslput _all_ / remote=task&amp;amp;REMRUN;

    /* Initialize child session */
    rsubmit task&amp;amp;REMRUN wait=no inheritlib = (work=share);
        options symbolgen mprint mlogic;

       %include "/home/programs/macros/winratio.sas" ;

       %local T;

       %do T = %scan(&amp;amp;tm,1) %to %scan(&amp;amp;tm,-1) ;
            %put ERROR: &amp;amp;T;
            %let FILEIN = derived.adttwinratio_tm&amp;amp;T.;
            %let FILEOUT = share.unstratified&amp;amp;T.;
            %put &amp;amp;FILEIN;
            %winratio( idsn=&amp;amp;FILEIN , byvar=timen , tgrp=&amp;amp;RX1 , odsn = &amp;amp;FILEOUT ) ;
       %end ;

    /* End child session */
    endrsubmit;
%mend doover;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Feb 2025 16:27:34 GMT</pubDate>
    <dc:creator>hartwell</dc:creator>
    <dc:date>2025-02-26T16:27:34Z</dc:date>
    <item>
      <title>Calling a macro inside SAS/CONNECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960287#M374557</link>
      <description>&lt;P&gt;I am having trouble calling a macro inside a SAS/CONNECT subsession with input parameters that are macro variables.&amp;nbsp; I have %included the macro inside the subsession and confirm that it is being found when called.&amp;nbsp; The issue comes with my use of macro variables inside the macro call (the &amp;amp;FILEIN and &amp;amp;FILEOUT parameters).&amp;nbsp; I have created these inside the subsession and used put statements to confirm that they are resolving exactly as they should be.&amp;nbsp; However, in the %winratio macro, I get an error that "Apparent symbolic reference to FILEIN not resolved" and the macro attempts to locate the dataset work.FILEIN.&amp;nbsp; Is there a way to get this to work or am I going to have to hard code my macro calls?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro doover (REMRUN=,tm= ) ; 
    %syslput _all_ / remote=task&amp;amp;REMRUN;

    /* Initialize child session */
    rsubmit task&amp;amp;REMRUN wait=no inheritlib = (work=share);
        options symbolgen mprint mlogic;

       %include "/home/programs/macros/winratio.sas" ;

       %local T;

       %do T = %scan(&amp;amp;tm,1) %to %scan(&amp;amp;tm,-1) ;
            %put ERROR: &amp;amp;T;
            %let FILEIN = derived.adttwinratio_tm&amp;amp;T.;
            %let FILEOUT = share.unstratified&amp;amp;T.;
            %put &amp;amp;FILEIN;
            %winratio( idsn=&amp;amp;FILEIN , byvar=timen , tgrp=&amp;amp;RX1 , odsn = &amp;amp;FILEOUT ) ;
       %end ;

    /* End child session */
    endrsubmit;
%mend doover;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Feb 2025 16:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960287#M374557</guid>
      <dc:creator>hartwell</dc:creator>
      <dc:date>2025-02-26T16:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro inside SAS/CONNECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960297#M374558</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/468664"&gt;@hartwell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you be able to paste the output from the log? Please turn on mprint and mlogic options before you run the code to capture the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Vj&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 17:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960297#M374558</guid>
      <dc:creator>Vj_Govindarajan</dc:creator>
      <dc:date>2025-02-26T17:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro inside SAS/CONNECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960300#M374559</link>
      <description>&lt;P&gt;How can you send macro variables before you create the remote session?&amp;nbsp; Do you really need to send every macro variable over?&amp;nbsp; The only ones you appear to be using are TM and RX1. Where does the value of RX1 some from?&amp;nbsp; It seems the code is expecting to magically have a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect the %DO loop (if it is running at all) is running in your LOCAL session since you cannot use that statement in the open code you are running in the remote session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not eliminate the macro logic in the remote session and avoid that confusion.&amp;nbsp; Instead just use a data step running in the remote session to generate your macro calls.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doover (REMRUN=,tm= ) ; 
%local T;
/* Initialize child session */
rsubmit task&amp;amp;REMRUN inheritlib = (work=share);
  options symbolgen mprint mlogic;
  %include "/home/programs/macros/winratio.sas" ;
endrsubmit;

/* Send macro variables to remote */
%syslput tm=&amp;amp;tm / remote=task&amp;amp;REMRUN;
%syslput rx1=&amp;amp;rx1 / remote=task&amp;amp;REMRUN;

/* Run a series of %WINRATIO calls in the remote session */
rsubmit taks&amp;amp;REMRUN wait=no;
data _null_;
  do t=%scan(&amp;amp;tm,1) to %scan(&amp;amp;tm,-1) ;
    call execute(cats('%nrstr(%winratio)'
     ,'(idsn=derived.adttwinratio_tm',t
     ,',byvar=timen'
     ,',tgrp=&amp;amp;RX1'
     ,',odsn=share.unstratified',t
     ,')'
    ));
  end;
run;
endrsubmit ;

%mend doover;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 17:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960300#M374559</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-26T17:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro inside SAS/CONNECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960306#M374560</link>
      <description>&lt;P&gt;Fantastic!&lt;/P&gt;&lt;P&gt;The %do was absolutely the issue.&amp;nbsp; Thank you so much for catching that&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&amp;nbsp; It's working beautifully now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To your other questions:&lt;/P&gt;&lt;P&gt;- The RX1 macro was created outside of the code snippet I included (it gets assigned in the autoexec)&lt;/P&gt;&lt;P&gt;- I definitely don't need to send all macro variables--I usually just start that way as I develop/troubleshoot.&lt;/P&gt;&lt;P&gt;- I've not had any issue sending macro variables to rsubmit sessions not yet created&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 17:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960306#M374560</guid>
      <dc:creator>hartwell</dc:creator>
      <dc:date>2025-02-26T17:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro inside SAS/CONNECT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960308#M374561</link>
      <description>&lt;P&gt;You must have&amp;nbsp; set your options for SAS so it will automatically spawn a new SAS session on your current machine/cluster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you would need to include SASCMD= option to spawn a local SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or the other options that tell SAS/Connect how to find and connect to the actual remote server and launch SAS on it so you can make the remote connection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it is interesting to me that it would let you add the INHERITEDLIB= option AFTER it has already made the remote session.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 18:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-macro-inside-SAS-CONNECT/m-p/960308#M374561</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-26T18:04:59Z</dc:date>
    </item>
  </channel>
</rss>

