<?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: Writing text strings &amp;amp; text files - using Line Feeds causes additional lines or trailing spa in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249272#M46872</link>
    <description>&lt;P&gt;You need RECFM=N if you want to write your own term-string. &amp;nbsp;You also need a format you are getting a extra space using LIST PUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   file "~/sigtest.txt" recfm=n;
   signature = 'AWS4-HMAC-SHA256' || '0a'x ||
              '20150915T124500Z' || '0a'x ||
              '20150915/us-east-1/s3/aws4_request' || '0a'x || 
              'ef7c45cc2b0f100ea5d65024643f5cbaf83e7ba2717108905acd605cfe17bc6b';
   l=length(signature);
   put signature $varying256. l;
   run;
data _null_;
   infile "~/sigtest.txt" recfm=f;
   input;
   list;
   run;   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1830i86E1BB56780CE96F/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2016 17:57:17 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2016-02-10T17:57:17Z</dc:date>
    <item>
      <title>Writing text strings &amp; text files - using Line Feeds causes additional lines or trailing spaces.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249117#M46827</link>
      <description>&lt;P&gt;I'm trying to create an AWS signature, however I can't get my Line Feeds (&lt;STRONG&gt;'0a'x&lt;/STRONG&gt;) to work exactly right when I'm trying to output a textfile of the string I want to hash. I'm using a textfile to check that the string (to be stored as a macro variable) is correct and can be hashed correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Due to the line feeds not being exact it's causing the hash to be different from what I'm expecting (even when hashing the string directly)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's what I have currently; from googling around various documents:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
  file "W:\sigtest.txt" TERMSTR=lf   recfm=v;
  signature = 'AWS4-HMAC-SHA256' || '0a'x ||
              '20150915T124500Z' || '0a'x ||
              '20150915/us-east-1/s3/aws4_request' || '0a'x || 
              'ef7c45cc2b0f100ea5d65024643f5cbaf83e7ba2717108905acd605cfe17bc6b';

  put signature;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However when I check the output in &lt;STRONG&gt;notepad++&lt;/STRONG&gt; I get the following:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1821i276E39AE5BB1F445/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="sig sas.PNG" title="sig sas.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I'm expecting the following:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1822i2F98D9F52A1470F1/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="sig std.PNG" title="sig std.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The extra line causes the hash to be different, however if I drop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TERMSTR=lf   recfm=v&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;recfm=f&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I get the requisite number of lines (4), but I have trailing blanks/spaces after the hash key, which I can't get rid of.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1824iAAF913469CC91EE9/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="sig sas2.PNG" title="sig sas2.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate any help anyone has for this problem.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 02:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249117#M46827</guid>
      <dc:creator>jp</dc:creator>
      <dc:date>2016-02-10T02:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Writing text strings &amp; text files - using Line Feeds causes additional lines or trailing spa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249272#M46872</link>
      <description>&lt;P&gt;You need RECFM=N if you want to write your own term-string. &amp;nbsp;You also need a format you are getting a extra space using LIST PUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   file "~/sigtest.txt" recfm=n;
   signature = 'AWS4-HMAC-SHA256' || '0a'x ||
              '20150915T124500Z' || '0a'x ||
              '20150915/us-east-1/s3/aws4_request' || '0a'x || 
              'ef7c45cc2b0f100ea5d65024643f5cbaf83e7ba2717108905acd605cfe17bc6b';
   l=length(signature);
   put signature $varying256. l;
   run;
data _null_;
   infile "~/sigtest.txt" recfm=f;
   input;
   list;
   run;   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1830i86E1BB56780CE96F/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 17:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249272#M46872</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-10T17:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Writing text strings &amp; text files - using Line Feeds causes additional lines or trailing spa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249294#M46879</link>
      <description>&lt;P&gt;My colleague suggested the following solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "W:\sigtest.txt" TERMSTR=lf   recfm=F lrecl=1;
  signature = 'AWS4-HMAC-SHA256' || '0a'x ||
              '20150915T124500Z' || '0a'x ||
              '20150915/us-east-1/s3/aws4_request' || '0a'x ||
              'ef7c45cc2b0f100ea5d65024643f5cbaf83e7ba2717108905acd605cfe17bc6b';

  put signature;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I will admit I'm not 100% sure how/why this is working but it seems to work. I'll take a look at your solution too data _null_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 20:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249294#M46879</guid>
      <dc:creator>jp</dc:creator>
      <dc:date>2016-02-10T20:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Writing text strings &amp; text files - using Line Feeds causes additional lines or trailing spa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249317#M46888</link>
      <description>&lt;P&gt;RECFM N and F are similar in that there is no record termination string, RECFM=N has no record structure while RECFM=F has logical structure (an external attribute). &amp;nbsp;Standing on the outside looking in both files look them same because they are (tested with unix diff)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example writes 133 one byte records. &amp;nbsp;You can drop the INFILE statement option TERMSTR it is ignored.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 21:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-text-strings-amp-text-files-using-Line-Feeds-causes/m-p/249317#M46888</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-10T21:29:11Z</dc:date>
    </item>
  </channel>
</rss>

