<?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: Wrinting a text file - problem with inserting a blank in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558561#M155900</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19791"&gt;@Filipvdr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The cause is as described here:&amp;nbsp;&lt;A href="http://support.sas.com/kb/4/368.html" target="_blank" rel="noopener"&gt;http://support.sas.com/kb/4/368.html&lt;/A&gt;&amp;nbsp;which is just normal SAS behaviour.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code as below could give you what you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file print;
  array wkt {3} $32767 (3*'123456789');
  WKT2='123456.89';

  do _i=1 to dim(wkt);
    _mv=ifn(substrn(wkt[_i],7,1)='.',1,0);
    put +(_mv) wkt[_i] @;
  end;

  stop;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2019 08:39:12 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-05-14T08:39:12Z</dc:date>
    <item>
      <title>Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558262#M155793</link>
      <description>&lt;P&gt;Hello, i'm using DI studio to output a text file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_; 
   set &amp;amp;SYSLAST; 
      attrib WKT1 length = $32767; 
      attrib WKT2 length = $32767; 
      attrib WKT3 length = $32767; 
      attrib WKT4 length = $32767; 
      attrib WKT5 length = $32767; 
      attrib WKT6 length = $32767; 
      attrib WKT7 length = $32767; 
      attrib WKT8 length = $32767; 
      attrib WKT9 length = $32767; 
      attrib WKT10 length = $32767; 
      attrib WKT11 length = $32767; 
      attrib WKT12 length = $32767; 
      attrib id length = $30; 
      attrib startdate length = $100; 
      attrib enddate length = $20; 
      attrib year length = $40; 
      attrib municipality length = $60; 
      attrib activity length = $60; 
      attrib status length = $30; 
      attrib pilot length = $100; 
      attrib synductisid length = $40; 
      attrib statussynductis length = $30; 
      attrib gipodid length = $60; 
      file "&amp;amp;aa_path.reload.municipalinitiatives.&amp;amp;ts..del" lrecl = 400000 dlm='|';
      
      if ( _n_ = 1 ) then 
         do;
            put 
               "WKT1|WKT2|WKT3|WKT4|WKT5|WKT6|WKT7|WKT8|WKT9|WKT10|WKT11|WKT12|id|startdate|enddate|year|municipality|activity|status|pilot|synductisid|statussynductis|gipodid";
               end;
   put 
      WKT1
      WKT2
      WKT3
      WKT4
      WKT5
      WKT6
      WKT7
      WKT8
      WKT9
      WKT10
      WKT11
      WKT12
      id
      startdate
      enddate
      year
      municipality
      activity
      status
      pilot
      synductisid
      statussynductis
      gipodid
      ;

run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When i'm outputting the file, it goes to another tool which will concatenates all o f the WKT fields.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When one of the WKT fields has a . as 7th character I want to start it with a space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;_output1;
set &amp;amp;_input1;
if index(WKT2,'.') = 7 then WKT2 = " " || strip(WKT2);
if index(WKT3,'.') = 7 then WKT3 = " " || strip(WKT3);
if index(WKT4,'.') = 7 then WKT4 = " " || strip(WKT4);
if index(WKT5,'.') = 7 then WKT5 = " " || strip(WKT5);
if index(WKT6,'.') = 7 then WKT6 = " " || strip(WKT6);
if index(WKT7,'.') = 7 then WKT7 = " " || strip(WKT7);
if index(WKT8,'.') = 7 then WKT8 = " " || strip(WKT8);
if index(WKT9,'.') = 7 then WKT9 = " " || strip(WKT9);
if index(WKT10,'.') = 7 then WKT10 = " " || strip(WT10);
if index(WKT11,'.') = 7 then WKT11 = " " || strip(WKT11); 
if index(WKT12,'.') = 7 then WKT12 = " " || strip(WKT12);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The problem is that i'm not seeing the " " in my output file. I tried with "BLA" instead of " " and that works..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 11:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558262#M155793</guid>
      <dc:creator>Filipvdr</dc:creator>
      <dc:date>2019-05-13T11:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558267#M155796</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19791"&gt;@Filipvdr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This has very likely nothing to do with DIS but how you write the text file.&lt;/P&gt;
&lt;P&gt;What is this "&lt;SPAN&gt;&amp;nbsp;it goes to another tool which will concatenates all o f the WKT fields&lt;/SPAN&gt;". Some "tools" SAS inclusive left align strings for printing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing you could try: Define for all your WKT fields a permanent $CHAR format as this will more likely maintain the leading blanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;attrib WKT1 length = $32767 format=$CHAR32767.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 May 2019 11:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558267#M155796</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-13T11:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558539#M155893</link>
      <description>&lt;P&gt;Hi Patrick, i tried your suggestion but same result...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i insert a tab '09'x it works.. but when inserting '20'x it doesn't give me a space in the output text file..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;_output1;
 set &amp;amp;_input1;
 if index(WKT2,'.') = 7 then WKT2 = '09'x || strip(WKT2);
 if index(WKT3,'.') = 7 then WKT3 = '09'x || strip(WKT3);
 if index(WKT4,'.') = 7 then WKT4 = '09'x || strip(WKT4);
 if index(WKT5,'.') = 7 then WKT5 = '09'x || strip(WKT5);
 if index(WKT6,'.') = 7 then WKT6 = '09'x || strip(WKT6);
 if index(WKT7,'.') = 7 then WKT7 = '09'x || strip(WKT7);
 if index(WKT8,'.') = 7 then WKT8 = '09'x || strip(WKT8);
 if index(WKT9,'.') = 7 then WKT9 = '09'x || strip(WKT9);
 if index(WKT10,'.') = 7 then WKT10 = '09'x || strip(WT10);
 if index(WKT11,'.') = 7 then WKT11 = '09'x || strip(WKT11); 
 if index(WKT12,'.') = 7 then WKT12 = '09'x || strip(WKT12);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 May 2019 06:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558539#M155893</guid>
      <dc:creator>Filipvdr</dc:creator>
      <dc:date>2019-05-14T06:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558561#M155900</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19791"&gt;@Filipvdr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The cause is as described here:&amp;nbsp;&lt;A href="http://support.sas.com/kb/4/368.html" target="_blank" rel="noopener"&gt;http://support.sas.com/kb/4/368.html&lt;/A&gt;&amp;nbsp;which is just normal SAS behaviour.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code as below could give you what you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file print;
  array wkt {3} $32767 (3*'123456789');
  WKT2='123456.89';

  do _i=1 to dim(wkt);
    _mv=ifn(substrn(wkt[_i],7,1)='.',1,0);
    put +(_mv) wkt[_i] @;
  end;

  stop;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 08:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558561#M155900</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-14T08:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558637#M155918</link>
      <description>&lt;P&gt;Can you explain what the overall goal of this process is?&lt;/P&gt;
&lt;P&gt;It looks like you have split an extremely long value into 12 long values.&amp;nbsp; Are you then trying to piece them back together?&lt;/P&gt;
&lt;P&gt;How were the 12 pieces created in the first place?&amp;nbsp; Is it possible that any of the pieces ended up being created with leading and/or trailing blanks?&amp;nbsp; And in the later processing do you need to preserve those blanks?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the PUT statement to preserve leading blanks then you need to use either $CHAR or $VARYING format when printing the value.&lt;/P&gt;
&lt;P&gt;But then the consumer of the file needs to also preserve the leading spaces and normally when reading a delimited file like what it looks like you are trying to create the leading/trailing spaces on a field are ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 14:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558637#M155918</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-14T14:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558645#M155921</link>
      <description>&lt;P&gt;Does it have to be an actual space?&amp;nbsp; Can you use some other character that looks like a space?&lt;/P&gt;
&lt;P&gt;Like the 'A0'x character that microsoft uses as a non-breaking space?&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 14:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558645#M155921</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-14T14:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558760#M155969</link>
      <description>&lt;P&gt;You may need to pay attention to the possibility of losing data if your existing value is actually &lt;SPAN class="token number"&gt;32767 characters after the strip function. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token number"&gt;An inserted character at the lead means that the last character of the original value will be lost.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data  example;
   length x $ 5;
   x = '12345';
   x = 'A'||strip(x);
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="token number"&gt;If this is a possibility you can't correct it by adding a character to the value. I would be tempted to look at use of conditional COLUMN pointer values instead of modifying values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token number"&gt;The following I am testing at position 5 because I'm too lazy to make longer variables for a simple example. Of course change the path and file name to something you can find.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data example;
   input row WKT2 $ WKT3 $ ;
   file "c:\path\junk.txt" dlm='|';
   put row @ ;
   if index(WKT2,'.') = 5 then put +1 wkt2 @; else put wkt2 @;
   if index(WKT3,'.') = 5 then put +1 wkt3 @; else put wkt3 @;
   put ;
datalines;
1 1245678 abcd.fg  
2 1234.678 abc      
3 12.4567 abcdefg.  
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 May 2019 20:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558760#M155969</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-14T20:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Wrinting a text file - problem with inserting a blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558801#M155990</link>
      <description>&lt;P&gt;Just&amp;nbsp; detail, but the char() function is better suited to this test than the index function&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;if index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;WKT12&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'.'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;7&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 04:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wrinting-a-text-file-problem-with-inserting-a-blank/m-p/558801#M155990</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-05-15T04:11:41Z</dc:date>
    </item>
  </channel>
</rss>

