<?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 Executing a dynamic command which is masked with NRSTR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426881#M281341</link>
    <description>&lt;P&gt;I'm sure I resolved this once before when dealing with URIs but I cannot for the life of me get this to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't like warnings, and the array of % symbols in this Unix command are causing about 15 warnings per loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example code which is contained within a DO loop in a %MACRO:&lt;/P&gt;&lt;PRE&gt;data _null_;
ps = %nrstr("ssh -o StrictHostKeyChecking=no ""&amp;amp;ServerName"" 'find /logdir/ -type f -printf ""%p|%TY-%Tm-%Td %TX|%AY-%Am-%Ad %AX|%s|%u|%U\n"" &amp;gt; &amp;amp;projDir./Data/output.&amp;amp;ServerName'");
call system(ps);
;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using NRSTR, the call system cannot resolve the entry "ps" which is created directly above it. I've also tried the same with a %let statement and then using call system(&amp;amp;ps.) but still, nothing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BQUOTE, NRBQUOTE, STR, etc, etc do not remove warnings (and in some cases, BQUOTE particularly, I get errors).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a working example where they have been able to construct a command with "'s, 's %'s and other symbols and can then execute against it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The closest I have got to a clean log is with NRSTR, but the output cannot be executed against.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 14:42:24 GMT</pubDate>
    <dc:creator>_Dan_</dc:creator>
    <dc:date>2018-01-11T14:42:24Z</dc:date>
    <item>
      <title>Executing a dynamic command which is masked with NRSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426881#M281341</link>
      <description>&lt;P&gt;I'm sure I resolved this once before when dealing with URIs but I cannot for the life of me get this to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't like warnings, and the array of % symbols in this Unix command are causing about 15 warnings per loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example code which is contained within a DO loop in a %MACRO:&lt;/P&gt;&lt;PRE&gt;data _null_;
ps = %nrstr("ssh -o StrictHostKeyChecking=no ""&amp;amp;ServerName"" 'find /logdir/ -type f -printf ""%p|%TY-%Tm-%Td %TX|%AY-%Am-%Ad %AX|%s|%u|%U\n"" &amp;gt; &amp;amp;projDir./Data/output.&amp;amp;ServerName'");
call system(ps);
;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using NRSTR, the call system cannot resolve the entry "ps" which is created directly above it. I've also tried the same with a %let statement and then using call system(&amp;amp;ps.) but still, nothing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BQUOTE, NRBQUOTE, STR, etc, etc do not remove warnings (and in some cases, BQUOTE particularly, I get errors).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a working example where they have been able to construct a command with "'s, 's %'s and other symbols and can then execute against it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The closest I have got to a clean log is with NRSTR, but the output cannot be executed against.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 14:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426881#M281341</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2018-01-11T14:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a dynamic command which is masked with NRSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426886#M281342</link>
      <description>&lt;P&gt;That code will not work as you are mixing datastep and macro code.&amp;nbsp; %nstr() is a macro itself.&amp;nbsp; With the data _null_ you already have the ability to process the data fully in a string:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  ps=cat('"ssh -o StrictHostKeyChecking=no ',"&amp;amp;ServerName",' find /logdir/ -type f -printf "%p|%TY-%Tm-%Td %TX|%AY-%Am-%Ad %AX|%s|%u|%U\n" &amp;gt; ',"&amp;amp;projDir.",'/Data/output.',"&amp;amp;ServerName",'"');
  call system(ps);
run;&lt;/PRE&gt;
&lt;P&gt;Or something along those lines.&amp;nbsp; Basically I am just concatenating the various parts of the string together using Base SAS string functions to get it looking as I want.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:07:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426886#M281342</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-11T15:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a dynamic command which is masked with NRSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426888#M281343</link>
      <description>&lt;P&gt;I don't have a working example, but I do have a suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that single quotes suppress all macro activity, while double quotes permit macro activity (needed to allow &amp;amp;ServerName to resolve).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an untested attempt at what you might be able to use to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ps = cat(&lt;FONT face="courier new,courier"&gt;"ssh -o StrictHostKeyChecking=no ""&amp;amp;ServerName"" 'find /logdir/ -type f -printf ",&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'"%p|%TY-%Tm-%Td %TX|%AY-%Am-%Ad %AX|%s|%u|%U\n"',&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp;gt; &amp;amp;projDir./Data/output.&amp;amp;ServerName'");&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;and I are thinking along similar lines.&amp;nbsp; You might need to see what the values are that get assigned to PS, and tweak the results&amp;nbsp;(such as where the quotes go)&amp;nbsp;since our suggestions are similar but not identical.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426888#M281343</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-11T15:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a dynamic command which is masked with NRSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426904#M281344</link>
      <description>&lt;P&gt;Hi there, thanks for your responses&lt;BR /&gt;&lt;BR /&gt;Single and double quoting isn't an unknown factor for me, so I'm happy with the understanding of how a macro variable will not be resolved within single quotes, which is what caused further issues because I could have wrapped the whole thing in single quotes and the issue would have gone away...&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;has provided a working solution, as it concatenates a working string within single quotes without physically wrapping it in single quotes, therefore the macro variables resolve, and the %s are hidden, which is exactly what I needed.&lt;BR /&gt;&lt;BR /&gt;Thanks again to both of you for your help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Dan&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-a-dynamic-command-which-is-masked-with-NRSTR/m-p/426904#M281344</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2018-01-11T15:52:23Z</dc:date>
    </item>
  </channel>
</rss>

