<?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: Reading Data That has Missing Spaces in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721618#M27802</link>
    <description>&lt;P&gt;Please post some sample of your input text file and the list of expected variables with their max length. Without that it is difficult to explain how to do what you want.&lt;/P&gt;
&lt;P&gt;One of possibilities is to read the whole record as one variable, compress it to remove spaces and then read by position. It needs to take in account string variables (text) - can a variable contain a space/s in between?&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2021 16:48:33 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2021-02-24T16:48:33Z</dc:date>
    <item>
      <title>Reading Data That has Missing Spaces</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721613#M27799</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use INFILE to read in a file that uses spaces as its delimiter, but has some variables that are missing spaces between them. The numeric variables are all a max of 2 characters long, but some end up being 8 or more because of their missing spaces. Is there a way to tell SAS only to read 2 characters into a numeric variable, and then move on even if there is no space following?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721613#M27799</guid>
      <dc:creator>cmcmains</dc:creator>
      <dc:date>2021-02-24T16:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data That has Missing Spaces</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721618#M27802</link>
      <description>&lt;P&gt;Please post some sample of your input text file and the list of expected variables with their max length. Without that it is difficult to explain how to do what you want.&lt;/P&gt;
&lt;P&gt;One of possibilities is to read the whole record as one variable, compress it to remove spaces and then read by position. It needs to take in account string variables (text) - can a variable contain a space/s in between?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721618#M27802</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-24T16:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data That has Missing Spaces</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721620#M27803</link>
      <description>&lt;P&gt;So an example would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;80123 10 20 30 40 50 60708090 10 20 30 40 50 60 70 80 90 10 20 30 40 50 60&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I would be using "INPUT code x1-x24" to get the first chunk as a code, then 24 variables each with 2 characters as their length. Does that explain it a bit better?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721620#M27803</guid>
      <dc:creator>cmcmains</dc:creator>
      <dc:date>2021-02-24T16:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data That has Missing Spaces</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721627#M27806</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/370904"&gt;@cmcmains&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to use INFILE to read in a file that uses spaces as its delimiter, but has &lt;STRONG&gt;some variables that are missing spaces between them.&lt;/STRONG&gt; The numeric variables are all a max of 2 characters long, but some end up being 8 or more because of their missing spaces. Is there a way to tell SAS only to read 2 characters into a numeric variable, and then move on even if there is no space following?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That mean you do not have a space delimited file. A delimited file by definition will have a delimiter between every variable.&lt;/P&gt;
&lt;P&gt;If the number of spaces varies between longer and shorter values then you almost certainly have either a TAB delimited file or fixed column data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And paste example data text into a TEXT box opened on the forum with the &amp;lt;/&amp;gt; icon. The message window will reformat white space, i.e. blanks, and what we see is very likely not what you have.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721627#M27806</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-24T17:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data That has Missing Spaces</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721630#M27807</link>
      <description>&lt;P&gt;If the 24 fields always contain exactly 2 digits then you could do something like this.&amp;nbsp; Read the ID then compress blanks and use column input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename FT15F001 temp;
data test;
   infile FT15F001 col=col missover;
   input ID @;
   putlog col=;
   _infile_ = compress(substrn(_infile_,col),' ');
   putlog _infile_;
   input @1 (x1-x24) (2.);
   parmcards;
80123 10 20 30 40 50 60708090 10 20 30 40 50 60 70 80 90 10 20 30 40 50 60
8012355 10 20 30 40 50 60708090 10 20 30 405060 70 809010 20 30 40 50 60
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 757px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55124i2AD28BB1C4CE998C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721630#M27807</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-02-24T17:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Data That has Missing Spaces</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721642#M27808</link>
      <description>&lt;P&gt;I understand that you have 24 numeric variables each is two digits.&lt;/P&gt;
&lt;P&gt;The minimum length of a record is 24x2=48. I assume max length is about 72.&lt;/P&gt;
&lt;P&gt;Check next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    infile "&amp;lt;path and file name&amp;gt;.txt" truncover;
    input code 5. a_line $char72.;
    a_line = compress(a_line,' '||'09'x); /* remove spaces and tabs  */
    array varx {*} x1-x24;
    do i=1 to length(a_line) by 2;
       varx(i) = input(substr(a_line,i,2),2.);
    end; drop i;
run;  
       &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-Data-That-has-Missing-Spaces/m-p/721642#M27808</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-24T17:48:27Z</dc:date>
    </item>
  </channel>
</rss>

