<?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: Resolve macro variable during signon in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901376#M356231</link>
    <description>&lt;P&gt;Could you be more specific? Exactly which macro variable, on which line of the code, isn't resolving properly?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2023 11:52:53 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-11-03T11:52:53Z</dc:date>
    <item>
      <title>Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901369#M356229</link>
      <description>&lt;P&gt;Hello to all,&lt;BR /&gt;In order to send files to external systems I have to do signons on some sas servers that communicate with external systems.&lt;BR /&gt;In particular my problem lies in the fact that during the signons with which I copy files from one server to another I can not solve the variable macro with the file name. Attached is the sample code.&lt;BR /&gt;The resolution function in the first signon in the second no&lt;BR /&gt;Will someone please help me?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro invio;

proc sql;
create table INSPECTION_FOR_SPM as 
select *
from dati.HSEQ4A_KPI_X_SPM
where Event_Date='202310';
quit;



data _null_;
date_=put(intnx('month',today(),-1),monyy7.);
put date_;
data_comp=compress(('SPM_KPI_HSEQALL_'||date_||'.csv'));
put data_comp;
call symput('file',data_comp);
run;

%let nome_file=&amp;amp;file.;
%put nome file---------------&amp;gt;&amp;amp;file.;




proc export data=INSPECTION_FOR_SPM outfile="/sasgrid/hseq/1_0/KPI_HSEQ4ALL_X_SPM/&amp;amp;nome_file." dbms=dlm replace label;
delimiter='|'; 
run;


/********************invio tramite sftp***************************/


filename locref "/sasgrid/hseq/1_0/KPI_HSEQ4ALL_X_SPM/&amp;amp;nome_file."; 
%let host=xxxxxxxxxx  7551;
options comamid=tcp remote=host noconnectmetaconnection;
signon userid="xxxxxxx\zsassystemuserdcc" password="{SAS002}03079E1140FD8F163EF93EB41335DE5D0D5A90AA49A7ED19";
%syslput file1=&amp;amp;nome_file.;
rsubmit;
options NETENCRALG=SSL;
filename outref "G:\&amp;amp;file1.";
Proc Upload
  infile=locref
  outfile=outref BINARY;
run;
 
data _null_;
call symput('host','elaawgsasa12.global 17551');
run;
options comamid=tcp remote=host noconnectmetaconnection;
signon userid="sassrv" password="sassrvadm";
filename locref "G:\&amp;amp;file2";
rsubmit;
 
filename outref "/sasgrid/hseq/1_0/KPI_HSEQ4ALL_X_SPM/&amp;amp;file2.";
Proc Upload
  infile=locref
  outfile=outref BINARY;
run;
 
/*
filename out sftp "/01_IMPORTED_KPI/&amp;amp;file2." host='ftp-enl.bravosolution.com' debug
cd='/01_IMPORTED_KPI/' user='enlusr01160' optionsx='-i /home/sassrv/.ssh/SPM_PVTK.ppk';

data _null_;
infile "/sasgrid/hseq/1_0/KPI_HSEQ4ALL_X_SPM/&amp;amp;file2." recfm=n ;
input x $char1. @@;
file out recfm=s;
put x $char1. @@;
run;
*/


endrsubmit;
endrsubmit;

%mend;

%invio;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Nov 2023 11:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901369#M356229</guid>
      <dc:creator>dipand</dc:creator>
      <dc:date>2023-11-03T11:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901376#M356231</link>
      <description>&lt;P&gt;Could you be more specific? Exactly which macro variable, on which line of the code, isn't resolving properly?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 11:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901376#M356231</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T11:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901378#M356232</link>
      <description>&lt;P&gt;Hi have problem with the resolution this macro variable&amp;nbsp;&amp;amp;nome_file. when I use the signon for copy the file to another server.&lt;/P&gt;
&lt;P&gt;I try to use the&amp;nbsp; %syslput ma this way resolve the macro variabile only first signon, while in the second signon :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;call symput('host','elaawgsasaxxxx 17551');&lt;BR /&gt;run;&lt;BR /&gt;%syslput file2=&amp;amp;file1.;&amp;nbsp; /************don't resolve the value ************/&lt;BR /&gt;options comamid=tcp remote=host noconnectmetaconnection;&lt;BR /&gt;signon userid="sassrv" password="sassrvadm";&lt;BR /&gt;filename locref "G:\&amp;amp;file2";&lt;BR /&gt;rsubmit;&lt;BR /&gt;&lt;BR /&gt;filename outref "/sasgrid/hseq/1_0/KPI_HSEQ4ALL_X_SPM/&amp;amp;file2.";&lt;BR /&gt;Proc Upload&lt;BR /&gt;infile=locref&lt;BR /&gt;outfile=outref BINARY;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 11:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901378#M356232</guid>
      <dc:creator>dipand</dc:creator>
      <dc:date>2023-11-03T11:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901380#M356234</link>
      <description>&lt;P&gt;What is the value of &amp;amp;file1 just before the %SYSLPUT command?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please put the command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;=file1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in your code, before %SYSLPUT and run it and show us the results of this command.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 12:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901380#M356234</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T12:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901385#M356238</link>
      <description>&lt;P&gt;If you are having trouble with the new(ish) %SYSLPUT statement you might try using the old autocall macro that SAS used to provide to send a macro variable to a remote session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a copy of the version that shipped with SAS 6.12&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/syslput612.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/syslput612.sas&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 13:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901385#M356238</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-03T13:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901420#M356241</link>
      <description>&lt;P&gt;Did you try it without the MACRO wrapper?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is probably the macro that is resolving the macro variable reference at the wrong time.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 15:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901420#M356241</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-03T15:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901423#M356243</link>
      <description>I attached the program</description>
      <pubDate>Fri, 03 Nov 2023 16:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901423#M356243</guid>
      <dc:creator>dipand</dc:creator>
      <dc:date>2023-11-03T16:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve macro variable during signon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901520#M356273</link>
      <description>&lt;P&gt;Best is to remove the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This simple example program works fine when submitted as "open" code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=local session;
%syslput mvar=remote1;
rsubmit remote1;
%put &amp;amp;=mvar;
endrsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log&lt;/P&gt;
&lt;PRE&gt;133  %let mvar=local session;
134  %syslput mvar=remote1;
135  rsubmit remote1;
NOTE: Remote submit to REMOTE1 commencing.
9    %put &amp;amp;=mvar;
MVAR=remote1
NOTE: Remote submit to REMOTE1 complete.&lt;/PRE&gt;
&lt;P&gt;But if you try that inside a macro.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test1;
%let mvar=local session;
%syslput mvar=remote1;
rsubmit remote1;
%put &amp;amp;=mvar;
endrsubmit;
%mend test1;
%test1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The %PUT runs on the LOCAL session.&lt;/P&gt;
&lt;PRE&gt;143  %test1;
MPRINT(TEST1):   rsubmit;
NOTE: Remote submit to REMOTE1 commencing.
MVAR=local session
MPRINT(TEST1):   endrsubmit;
NOTE: Remote submit to REMOTE1 complete.&lt;/PRE&gt;
&lt;P&gt;If you just use %NRSTR() to protect the remote macro macro code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test2;
%let mvar=local session;
%syslput mvar=remote1;
rsubmit remote1;
%nrstr(%put &amp;amp;=mvar;)
endrsubmit;
%mend test2;
%test2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It will print the value of the remote macro variable.&lt;/P&gt;
&lt;PRE&gt;151  %test2;
MPRINT(TEST2):   rsubmit;
NOTE: Remote submit to REMOTE1 commencing.
MPRINT(TEST2):   %put &amp;amp;=mvar;
MPRINT(TEST2):   endrsubmit;
10    %put &amp;amp;=mvar;
MVAR=remote1
NOTE: Remote submit to REMOTE1 complete.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 02:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-macro-variable-during-signon/m-p/901520#M356273</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-04T02:17:33Z</dc:date>
    </item>
  </channel>
</rss>

