<?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: Using pipe with % in text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882221#M348565</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114275"&gt;@bsas94&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would rather omit the single quotes in the %LET statement and instead use the %NRSTR function to mask the percent sign and the semicolon:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let line = %nrstr(%put NOTE: foo;);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use the %TSLIT macro (see&amp;nbsp;&lt;A href="https://support.sas.com/kb/25/076.html" target="_blank" rel="noopener"&gt;Sample 25076: Resolve a macro variable within single quotation marks&lt;/A&gt;) in the INFILE statement to add quotes where needed. Apparently, you are on a Unix system, whereas my suggestions below were tested on a Windows workstation (using a different path, of course).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To append the SAS code&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%put NOTE: foo;&lt;/FONT&gt; &lt;EM&gt;without&lt;/EM&gt; quotes to a text file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile %tslit(echo &amp;amp;line &amp;gt;&amp;gt; /opt/testfolder/test_program.sas) pipe;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To append&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;%put NOTE: foo;'&lt;/FONT&gt; &lt;EM&gt;including&lt;/EM&gt;&amp;nbsp;the single quotes to a text file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile %tslit(echo %tslit(&amp;amp;line) &amp;gt;&amp;gt; /opt/testfolder/test_program.sas) pipe;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jun 2023 20:09:57 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2023-06-23T20:09:57Z</dc:date>
    <item>
      <title>Using pipe with % in text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882165#M348542</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been trying to execute the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let line = '%put NOTE: foo;';

data _null_;
 infile "echo &amp;amp;line. &amp;gt;&amp;gt; /opt/testfolder/test_program.sas" pipe;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, when getting the results from the execution, the file I'm trying to append is not appended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I remove the "%" character from the first line, the command works just fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How could I achieve the desired result (writing this piece of code to a file)? I've tried to use some functions such as str, nrstr, quote and nrquote and I wasn't able to execute it properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 16:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882165#M348542</guid>
      <dc:creator>bsas94</dc:creator>
      <dc:date>2023-06-23T16:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using pipe with % in text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882221#M348565</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114275"&gt;@bsas94&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would rather omit the single quotes in the %LET statement and instead use the %NRSTR function to mask the percent sign and the semicolon:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let line = %nrstr(%put NOTE: foo;);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use the %TSLIT macro (see&amp;nbsp;&lt;A href="https://support.sas.com/kb/25/076.html" target="_blank" rel="noopener"&gt;Sample 25076: Resolve a macro variable within single quotation marks&lt;/A&gt;) in the INFILE statement to add quotes where needed. Apparently, you are on a Unix system, whereas my suggestions below were tested on a Windows workstation (using a different path, of course).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To append the SAS code&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%put NOTE: foo;&lt;/FONT&gt; &lt;EM&gt;without&lt;/EM&gt; quotes to a text file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile %tslit(echo &amp;amp;line &amp;gt;&amp;gt; /opt/testfolder/test_program.sas) pipe;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To append&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;%put NOTE: foo;'&lt;/FONT&gt; &lt;EM&gt;including&lt;/EM&gt;&amp;nbsp;the single quotes to a text file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile %tslit(echo %tslit(&amp;amp;line) &amp;gt;&amp;gt; /opt/testfolder/test_program.sas) pipe;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 20:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882221#M348565</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-06-23T20:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using pipe with % in text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882238#M348573</link>
      <description>&lt;P&gt;Huh?&lt;/P&gt;
&lt;P&gt;Aren't you making this way too complicated?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "/opt/testfolder/test_program.sas" mod;
  put '%put NOTE: foo;';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have the value in a macro variable use SYMGET() to get it into a character variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "/opt/testfolder/test_program.sas" mod;
  length line $200;
  line = symget('line');
  put line ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2023 23:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-pipe-with-in-text/m-p/882238#M348573</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-23T23:52:38Z</dc:date>
    </item>
  </channel>
</rss>

