<?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: Log displays &amp;quot;Invalid data&amp;quot; when reading a range of variables using formatted input in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248622#M46716</link>
    <description>Remove the 7. entirely. You can add an informat if your data requires it but it doesn't.</description>
    <pubDate>Mon, 08 Feb 2016 05:18:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-02-08T05:18:32Z</dc:date>
    <item>
      <title>Log displays "Invalid data" when reading a range of variables using formatted input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248575#M46702</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm preparing for the Base SAS Programming certification and am currently reading chapter 17: reading free-format data (Third Edition). I tried executing the code snippet on page 543, in which the data step reads a range of numeric variables and specifies a format for it. I am working on SAS University Edition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is my &lt;EM&gt;code&lt;/EM&gt; snippet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename sf '/folders/myfolders/salesfmtd.txt';
data salesfmtd;
	infile sf;
	input Name $ (Sales1-Sales3) (7.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The salesfmtd.txt &lt;EM&gt;file&lt;/EM&gt; has the following contents:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X 1500 1280 1800&lt;BR /&gt;Y 1260 1700.345 1900&lt;BR /&gt;Z 1600.076 1450 1720&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;output data&lt;/EM&gt; contains just one record as follows:&lt;/P&gt;&lt;P&gt;X . . .&lt;/P&gt;&lt;P&gt;i.e. the values are missing and represented by a period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;log&lt;/EM&gt; displays the following notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for Sales1 in line 1 3-9.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for Sales2 in line 1 10-16.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for Sales3 in line 2 1-7.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;2 Y 1260 1700.345 1900 20&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data errors for file SF occurred outside the printed range.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Increase available buffer lines with the INFILE n= option.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Name=X Sales1=. Sales2=. Sales3=. _ERROR_=1 _N_=1&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for Sales2 in line 3 10-16.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: LOST CARD.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data errors for file SF occurred outside the printed range.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Increase available buffer lines with the INFILE n= option.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Name=Z Sales1=1600.07 Sales2=. Sales3=. _ERROR_=1 _N_=2&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: 3 records were read from the infile SF.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;The minimum record length was 16.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;The maximum record length was 20.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.SALESFMTD has 1 observations and 4 variables.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.02 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Can someone please tell me where the problem lies? I don't see why there could be a problem with specifying 7. as the format.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Thanks in advance!&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 20:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248575#M46702</guid>
      <dc:creator>essaykay</dc:creator>
      <dc:date>2016-02-07T20:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Log displays "Invalid data" when reading a range of variables using formatted input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248588#M46703</link>
      <description>&lt;P&gt;Your range of variables are not character or formated. So you do not nedd to&amp;nbsp;&lt;SPAN&gt;enclose them in&amp;nbsp;&lt;SPAN&gt;parentheses.&lt;BR /&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;This will work&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Name $ Sales1-Sales3 7.;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Feb 2016 22:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248588#M46703</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-07T22:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Log displays "Invalid data" when reading a range of variables using formatted input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248620#M46715</link>
      <description>&lt;P&gt;Thanks for your reply, Zaki. I modified the code according to what you said, but I still didn't get the desired output.&lt;/P&gt;&lt;P&gt;Following are the &lt;EM&gt;log&lt;/EM&gt; messages:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for Sales3 in line 2 1-7.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;2 Y 1260 1700.345 1900 20&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Name=X Sales1=1500 Sales2=1280 Sales3=. _ERROR_=1 _N_=1&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: LOST CARD.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Name=Z Sales1=1600.076 Sales2=1450 Sales3=. _ERROR_=1 _N_=2&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: 3 records were read from the infile SF.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;The minimum record length was 16.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;The maximum record length was 20.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.SALESFMTD has 1 observations and 4 variables.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Following is the output:&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;X 1500 1280 &lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 08 Feb 2016 04:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248620#M46715</guid>
      <dc:creator>essaykay</dc:creator>
      <dc:date>2016-02-08T04:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Log displays "Invalid data" when reading a range of variables using formatted input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248622#M46716</link>
      <description>Remove the 7. entirely. You can add an informat if your data requires it but it doesn't.</description>
      <pubDate>Mon, 08 Feb 2016 05:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248622#M46716</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-08T05:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Log displays "Invalid data" when reading a range of variables using formatted input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248717#M46733</link>
      <description>&lt;P&gt;As you're preparing for the certification, you should have come across the terms "&lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl/en/lestmtsref/68024/HTML/default/p0f9yk6pd4znukn1rlw6hzkg1url.htm" target="_blank"&gt;formatted input&lt;/A&gt;" and "&lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl/en/lestmtsref/68024/HTML/default/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_blank"&gt;list input&lt;/A&gt;." Your raw data file seems to be space-delimited and the column widths vary between observations. This is a typical situation&amp;nbsp;calling for list input. You &lt;EM&gt;can&lt;/EM&gt; specify informats in the (list) INPUT statement (or, alternatively, in an INFORMAT statement) -- this is then called &lt;EM&gt;modified&lt;/EM&gt; list input --, but the syntax for this requires the informat names to be prefixed with colons:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Name $ (Sales1-Sales3) (:7.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above INPUT statement should work well with your data. All four variables are read using list input. Without the colon, Sales1 - Sales3 would be read using formatted input, which has implications on&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt; where&lt;/EM&gt; data is read and&lt;/LI&gt;
&lt;LI&gt;where the &lt;EM&gt;pointer&lt;/EM&gt; is located after reading a value.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;(For details please see the documentation or, for another user's example, &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/how-to-do-I-know-when-to-skip-a-column-in-the-quot-input-quot/m-p/246669" target="_blank"&gt;this older thread&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As Reeza pointed out, there is actually no need to specify informat 7. here (the values are read correctly by default). Also, the width specification of&amp;nbsp;an informat used in&amp;nbsp;modified list input (&lt;U&gt;not:&lt;/U&gt; formatted input) is ignored anyway in the reading process.* So, in your example you could even specify informat 1. (which looks as if it was way too short for your numeric raw data values) and nevertheless all the digits would be read correctly with modified list input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*&amp;nbsp;(But it&amp;nbsp;does&amp;nbsp;have an impact on the length of character variables if their length has not been set&amp;nbsp;previously!)&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 21:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-displays-quot-Invalid-data-quot-when-reading-a-range-of/m-p/248717#M46733</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-08T21:06:56Z</dc:date>
    </item>
  </channel>
</rss>

