<?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: %str masking problem in a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647614#M193840</link>
    <description>&lt;P&gt;I don't get how the %STR() helps solve the problem you described.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want the macro variable defined on the remote machine, not on the local machine where the %UPLOAD macro is running.&lt;/P&gt;
&lt;P&gt;Try the %SYSLPUT function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro upload;
signon;
%syslput libws = libname wlib "test/path/on/windows" ;
rsubmit;
&amp;amp;libws;
proc upload inlib=hostlib outlib=wlib;
  select &amp;lt;dataset&amp;gt;;
quit;
endrsubmit;
signoff;
%mend upload;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have trouble using %SYSLPUT inside of a macro then try using the old style method of pushing macro variable definitions to remote process.&amp;nbsp;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 20:31:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-05-13T20:31:29Z</dc:date>
    <item>
      <title>%str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647593#M193832</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to transfer a dataset from host to windows server. &amp;nbsp;I use a customized macro that creates a connection between the host and the windows server.&amp;nbsp;&amp;nbsp;The problem is that I define the windows server path via a macro variable as below -&lt;/P&gt;&lt;P&gt;%let test = %str(Libname librer "test/path/on/windows");&lt;/P&gt;&lt;P&gt;&amp;amp;test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some validations to be done on host server prior connecting to windows, so I will have to pass the above lines in macro call, but since I pass the libname reference using %str, I get an error that the lib name can't be resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please assist me here.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;KK&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 19:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647593#M193832</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2020-05-13T19:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647597#M193833</link>
      <description>If %strong causes a problem, remove it.  There's nothing about the code you have shown that requires %str.</description>
      <pubDate>Wed, 13 May 2020 19:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647597#M193833</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-05-13T19:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647598#M193834</link>
      <description>&lt;P&gt;Why did you wrap that string inside of %STR()? What is it that you are trying to protect from the macro processor?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test = libname librer "test/path/on/windows" ;
&amp;amp;test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is it that you are actually doing, it is hard to tell from your explanation.&amp;nbsp; Can you present a simplified piece of code that replicates the issue?&lt;/P&gt;
&lt;P&gt;If you just want to remove macro quoting from a macro variable's value use the %UNQUOTE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%unquote(&amp;amp;test);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 19:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647598#M193834</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-13T19:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647608#M193838</link>
      <description>&lt;P&gt;Thanks for the response. I can't mention the libname statement directly in the macro without passing it through %str, as my process would comment out all the libname at the end, so that's why I want to mask the libname.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The resolving of libname fails online the below case, since the %str does not work when called inside the macro %upload.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro host_check;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%if %sysfuncn(libref(hostlib)) = 0 %then&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%upload;&lt;/P&gt;&lt;P&gt;%mend host_check;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro upload;&lt;/P&gt;&lt;P&gt;rsubmit;&lt;/P&gt;&lt;P&gt;%let libws = %str(libname wlib "test/path/on/windows");&lt;/P&gt;&lt;P&gt;&amp;amp;libws;&lt;/P&gt;&lt;P&gt;proc upload inlib=hostlib outlib=wlib;&lt;/P&gt;&lt;P&gt;select &amp;lt;dataset&amp;gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;endrsubmit;&lt;/P&gt;&lt;P&gt;signoff;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error message:&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;&amp;amp;libws&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;Apparent symbolic reference libws is not resolved&lt;/P&gt;&lt;P&gt;Error 180-322 Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;Kindly assist.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 20:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647608#M193838</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2020-05-13T20:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647614#M193840</link>
      <description>&lt;P&gt;I don't get how the %STR() helps solve the problem you described.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want the macro variable defined on the remote machine, not on the local machine where the %UPLOAD macro is running.&lt;/P&gt;
&lt;P&gt;Try the %SYSLPUT function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro upload;
signon;
%syslput libws = libname wlib "test/path/on/windows" ;
rsubmit;
&amp;amp;libws;
proc upload inlib=hostlib outlib=wlib;
  select &amp;lt;dataset&amp;gt;;
quit;
endrsubmit;
signoff;
%mend upload;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have trouble using %SYSLPUT inside of a macro then try using the old style method of pushing macro variable definitions to remote process.&amp;nbsp;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 20:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647614#M193840</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-13T20:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647631#M193844</link>
      <description>Thanks for the response again. I used %SYSLPUT too but still the libname for the windows server is not recognized and getting the same macro resolving failed error :(. I still wonder as to why it is not getting resolved.&lt;BR /&gt;</description>
      <pubDate>Wed, 13 May 2020 21:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647631#M193844</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2020-05-13T21:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647635#M193848</link>
      <description>&lt;P&gt;Please be more specific about the error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start by running code without any macro variables or macros.&lt;/P&gt;
&lt;P&gt;Does this work?&amp;nbsp; That path does not look valid. Why would you call it "path on windows" and / instead \ as the delimiter between folders? Why does it not start with / or drive letter or \\server ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rsubmit;
libname wlib "test/path/on/windows" ;
endrsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps you just need %nrstr() instead of %str()?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 21:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647635#M193848</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-13T21:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647640#M193850</link>
      <description>Sorry, the paths that I mentioned was only a dummy path I framed to show an example(corrected them as below). When I define libname directly as below , they work perfectly fine, but problem comes only when I want to refer the libname by a macro variable.&lt;BR /&gt;rsubmit;&lt;BR /&gt;libname wlib "c:\test\myfiles" ;&lt;BR /&gt;endrsubmit;</description>
      <pubDate>Wed, 13 May 2020 21:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647640#M193850</guid>
      <dc:creator>Kirtid</dc:creator>
      <dc:date>2020-05-13T21:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: %str masking problem in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647644#M193852</link>
      <description>&lt;P&gt;So build it slowly.&amp;nbsp; First check if you can actually set a macro variable in the remote session and return it to the local session.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%syslput rvar=This is remote variable value;
rsubmit;
%sysrput lvar=&amp;amp;rvar;
endrsubmit;
%put &amp;amp;=lvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also try removing so much macro code from the problem. For example you can make a libref using the LIBNAME statement in a data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rsubmit;
data _null_;
  rc=libname('wlib',"c:\test\myfiles") ;
  put rc=;
run;
endrsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can reference a macro variable in a data step using the SYMGET() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%syslput path=c:\test\myfiles;
rsubmit;
data _null_;
  rc=libname('wlib',symget('path'));
  put rc=;
run;
endrsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 21:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-masking-problem-in-a-macro/m-p/647644#M193852</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-13T21:59:24Z</dc:date>
    </item>
  </channel>
</rss>

