<?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 Tab delimited file with non standard data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367995#M87680</link>
    <description>&lt;P&gt;Hi Tom, This is awesome too! It's perfectly working. Your contribution is much appreciated. Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 17 Jun 2017 22:43:27 GMT</pubDate>
    <dc:creator>Data_User</dc:creator>
    <dc:date>2017-06-17T22:43:27Z</dc:date>
    <item>
      <title>Input Files usage in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367961#M87671</link>
      <description>&lt;P&gt;Hi,&lt;/P&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;&lt;P&gt;filename inp 'C:\Users\DATA3.txt';&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;infile inp dlm='09'x pad missover truncover firstobs=2;&lt;BR /&gt;input&lt;/P&gt;&lt;P&gt;Field1 $&lt;BR /&gt;Field2&lt;BR /&gt;Field3 $&lt;BR /&gt;Field4 $&lt;BR /&gt;Field5&lt;BR /&gt;Field6 $&lt;BR /&gt;Field7&lt;BR /&gt;Field8&lt;BR /&gt;Field9;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 23:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367961#M87671</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-06-22T23:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367972#M87672</link>
      <description>&lt;P&gt;Try with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile inp dlm='09'x dsd truncover firstobs=2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Jun 2017 20:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367972#M87672</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-06-17T20:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367976#M87673</link>
      <description>&lt;P&gt;I used PROC IMPORT to read your sample file. &amp;nbsp;The log showed 10 fields, rather than 9. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I opened up the file in Notepad++ with the "show tab" option. &amp;nbsp;In the screen shot below, the tabs are the orange arrows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9460iA40250B5576199CA/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Notepad++ can show tabs in tab delimited file.jpg" title="Notepad++ can show tabs in tab delimited file.jpg" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I copied the code in the log that PROC IMPORT generated, then modified it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME inp "/folders/myfolders/SAS Communities/DATA3.txt";

data WORK.WANT;
	%let _EFIERR_ = 0;

	/* set the ERROR detection macro variable */
	infile INP delimiter='09'x MISSOVER DSD firstobs=2;
	input field1 $
          field2 
          field3 $
          field4 $
          field5 
          field6 $
          field7 $
          field8 
          field9 
          field10;

	if _ERROR_ then
		call symputx('_EFIERR_', 1);

	/* set ERROR detection macro variable */
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There's a note in the log about invalid data for field8 line 254. &amp;nbsp;The numeric value has quotes around it, so that value is missing in the WANT data set.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 21:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367976#M87673</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2017-06-17T21:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367978#M87674</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the above option, but it's not working. Getting the below error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Invalid data for Field7 in line 2 30-32.&lt;BR /&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 21:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367978#M87674</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-06-17T21:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367984#M87675</link>
      <description>&lt;P&gt;Wow! This is awesome&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12496"&gt;@SuzanneDorinski&lt;/a&gt;. It's working. Thanks a lot for looking into this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the only problem I have noticed is if you see the input file the value for Material Variable is "10000000000000" but in SAS it's reading as "10000000". Can we fix this by any chance?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 17 Jun 2017 21:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367984#M87675</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-06-17T21:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367985#M87676</link>
      <description>&lt;P&gt;Looks like field3 needs to have the length set as 14.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.WANT;

    length field3 $ 14;
    
	%let _EFIERR_ = 0;

	/* set the ERROR detection macro variable */
	infile INP delimiter='09'x MISSOVER DSD firstobs=2;
	input field1 $
          field2 
          field3 $
          field4 $
          field5 
          field6 $
          field7 $
          field8 
          field9 
          field10;

	if _ERROR_ then
		call symputx('_EFIERR_', 1);

	/* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Jun 2017 21:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367985#M87676</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2017-06-17T21:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367986#M87677</link>
      <description>&lt;P&gt;Fentastic! It's working&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12496"&gt;@SuzanneDorinski&lt;/a&gt;. Appreciate your help on this!. Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 21:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367986#M87677</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-06-17T21:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367994#M87679</link>
      <description>&lt;P&gt;In your data file your header line has 16 fields and the data lines have 10 fields, but the 6th one is totally empty.&lt;/P&gt;
&lt;P&gt;So here is a way to read that and ignore the empty one. Also some of the values have commas, which you can handle with the COMMA informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is really much easier to define the variables first rather than attempting to define them via the INPUT statement. &amp;nbsp;If some of the variables need informats to read the source file properly then use an INFORMAT statement. &amp;nbsp;In this case we can just read all of the numbers using the COMMA. informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To skip the empty 6th column you can first read the first 6 columns into FIELD1 to 6 and then read the next four columns into FIELD6 to 9.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "&amp;amp;path\DATA3.txt" dsd dlm='09'x truncover firstobs=2;
  length field1 $3 field2 8 field3 $14 field4 $2 field5 8 field6 $3 field7 8 field8 8 field9 8 ;
  informat _numeric_ comma.;
  input field1-field6 field6-field9;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 22:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367994#M87679</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-17T22:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Tab delimited file with non standard data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367995#M87680</link>
      <description>&lt;P&gt;Hi Tom, This is awesome too! It's perfectly working. Your contribution is much appreciated. Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 22:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Files-usage-in-SAS/m-p/367995#M87680</guid>
      <dc:creator>Data_User</dc:creator>
      <dc:date>2017-06-17T22:43:27Z</dc:date>
    </item>
  </channel>
</rss>

