<?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: Inserting white spaces at the end of string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479456#M123773</link>
    <description>&lt;P&gt;Most times reading the documentation is enlightening. The file-statment has an option called "pad" controlling "whether records written to an external file are padded with blanks to the length that is specified in the LRECL= option."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need the options lrecl=480 and pad in your file-statement. Instead of pad you could use recfm=f.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jul 2018 11:33:18 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-07-19T11:33:18Z</dc:date>
    <item>
      <title>Inserting white spaces at the end of string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479437#M123763</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one file details.txt with data:-&lt;/P&gt;&lt;PRE&gt;ajay    manager    account    45000
sunil   clerk      account    25000
varun   manager    sales      50000
amit    manager    account    47000
tarun   peon       sales      15000
deepak  clerk      sales      23000
sunil   peon       sales      13000
satvik  director   purchase   80000&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I want output file out.txt same as input file details.txt but want spaces after datas to make all rows of 480bytes long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;To achieve this i have did :-&lt;/P&gt;&lt;P&gt;=============================================================================================&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA readFile;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFILE '/home/inputFile/details.txt';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INPUT line $ 1-35;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE TABLE final(data char(480));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INSERT INTO final(data) select line FROM readFile;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC REPORT DATA=final NOHEADER;&lt;/P&gt;&lt;P&gt;RUN;&lt;BR /&gt;FILNAME zout '/home/output/out.txt';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA _null_;&lt;BR /&gt;&amp;nbsp; SET final end=eof;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * set the dataset final ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RETAIN fid 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ eq 1 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fid = fopen('zout','O');&lt;/P&gt;&lt;P&gt;&amp;nbsp; if fid gt 0 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = fput(fid,data);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * data is a variable of dataset final ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = fwrite(fid,'P');&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if eof then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = fclose(fid);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;FILNAME zout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=============================================================================================&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but in output file i got each row of length 256 bytes but i want it 480 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance...&lt;/P&gt;&lt;P&gt;Please provide me a solution to achieve my desired output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 10:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479437#M123763</guid>
      <dc:creator>yadaw</dc:creator>
      <dc:date>2018-07-19T10:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting white spaces at the end of string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479445#M123764</link>
      <description>&lt;P&gt;Use the lrecl= option in the filename statement to increase the buffer size (default is 256).&lt;/P&gt;
&lt;P&gt;But why don't you do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile '/home/inputFile/details.txt' truncover;
file '/home/output/out.txt' lrecl=480;
input line $480.;
put line $480.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 10:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479445#M123764</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-19T10:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting white spaces at the end of string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479456#M123773</link>
      <description>&lt;P&gt;Most times reading the documentation is enlightening. The file-statment has an option called "pad" controlling "whether records written to an external file are padded with blanks to the length that is specified in the LRECL= option."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need the options lrecl=480 and pad in your file-statement. Instead of pad you could use recfm=f.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 11:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-white-spaces-at-the-end-of-string/m-p/479456#M123773</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-19T11:33:18Z</dc:date>
    </item>
  </channel>
</rss>

