<?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: Issue with input and datalines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668744#M200513</link>
    <description>&lt;P&gt;Afaik there is an option in SAS Studio to convert tabs to spaces automatically. Turning it on should also prevent such errors. But the best thing to do is simply not to use tab after the first visible char.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jul 2020 06:26:38 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-07-13T06:26:38Z</dc:date>
    <item>
      <title>Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668623#M200450</link>
      <description>&lt;P&gt;Greetings, I am using SAS University Edition and I am getting some issues with the following script. I expect it to accept the numeric values but it does not.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data MySample1;&lt;BR /&gt;input Firstfield secondfield thirdfield;&lt;BR /&gt;datalines;&lt;BR /&gt;123 34 54&lt;BR /&gt;21 35 33&lt;BR /&gt;1 32 34&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;Proc Print Data=Sample;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Firstfield secondfield thirdfield1&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for Firstfield in line 76 1-9.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for secondfield in line 77 1-8.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for thirdfield in line 78 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;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 CHAR 1.32.34&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;ZONE 30330332222222222222222222222222222222222222222222222222222222222222222222222222&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;NUMR 19329340000000000000000000000000000000000000000000000000000000000000000000000000&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data errors for file CARDS 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;Firstfield=. secondfield=. thirdfield=. _ERROR_=1 _N_=1&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.MYSAMPLE11 has 1 observations and 3 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.00 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;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;80 run;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81 Proc Print Data=MySample11;Run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: There were 1 observations read from the data set WORK.MYSAMPLE11.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;</description>
      <pubDate>Sun, 12 Jul 2020 01:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668623#M200450</guid>
      <dc:creator>amt11189</dc:creator>
      <dc:date>2020-07-12T01:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668624#M200451</link>
      <description>&lt;P&gt;Sorry Data line should read&amp;nbsp;&lt;SPAN&gt;data MySample11 "But the error is the same".&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 01:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668624#M200451</guid>
      <dc:creator>amt11189</dc:creator>
      <dc:date>2020-07-12T01:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668631#M200454</link>
      <description>&lt;P&gt;The ZONE and NUMR lines provide the answer to your question. &amp;nbsp; Those lines, which are synchronized with each other show the first 4 bits (ZONE) and second 4 bits (NUMR) of each byte in the lines of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since 4 bits ranges from 0000 to 1111, the lines actually print the corresponding hexadecimal characters (0000=0,0001=1,..., 1001=9,1010=A,....1111=F).&amp;nbsp; So, in ascii, if ZONE=3 and NUMR=1&amp;nbsp; ('31'x in hexadecimal notation), you have the ascii code for character "1".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, in the datalines you show, it appears that the 3 numbers in each line are separated by blanks, which would be '20'x.&amp;nbsp; But instead of '20'x you have '09'x separating the numeric fields, which is not a blank, but a tab character.&amp;nbsp; SAS University apparently defaults to using blanks as delimiters, not tab. &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if you don't change all your tab characters to blank, then you can fix this with the DLM option on the INFILE statement, telling SAS to consider tab characters as delimiters, and not to look for blank delimiters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
  infile datalines dlm='09'x;
  input x y z;
datalines;
1	2
3	4
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have BOTH tabs and spaces as delimiters, then expand the DLM= parameter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
  infile datalines dlm='0920'x;
  input x y z;
datalines;
1	2
3	4
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 03:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668631#M200454</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-07-12T03:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668715#M200498</link>
      <description>&lt;P&gt;That is one of the differences between SAS/Studio and Display Manager.&amp;nbsp; In Display Manager the program editor will replace the tabs in your program with spaces and then your code would work as is.&amp;nbsp; In SAS/Studio somehow the actual tabs end up in the program stream that is passed to SAS.&amp;nbsp; So the input sees&amp;nbsp;&lt;SPAN&gt;123&amp;lt;tab&amp;gt;34&amp;lt;tab&amp;gt;54 as one word to read and since it is not a valid number you get that error message and a missing value for Firstfield.&amp;nbsp; Since that is the last word on the line the input statement moves to the second line to find data for the second variable where the same problem exists.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Don't put tabs into your data. In fact don't put tabs into any of your SAS code.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 23:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668715#M200498</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-12T23:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668744#M200513</link>
      <description>&lt;P&gt;Afaik there is an option in SAS Studio to convert tabs to spaces automatically. Turning it on should also prevent such errors. But the best thing to do is simply not to use tab after the first visible char.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 06:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668744#M200513</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-07-13T06:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668746#M200514</link>
      <description>&lt;P&gt;This:&lt;/P&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier"&gt;78 CHAR 1.32.34&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;ZONE 3&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt;33&lt;FONT color="#FF0000"&gt;0&lt;/FONT&gt;33&lt;FONT color="#FF0000"&gt;2222222222222222222222222222222222222222222222222222222222222222222222222&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#000000"&gt;NUMR 1&lt;FONT color="#FF0000"&gt;9&lt;/FONT&gt;32&lt;FONT color="#FF0000"&gt;9&lt;/FONT&gt;34&lt;FONT color="#FF0000"&gt;0000000000&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;000000000000000000000000000000000000000000000000000000000000000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;P&gt;reads as:&lt;/P&gt;
&lt;P&gt;hex 31 which is 1&lt;/P&gt;
&lt;P&gt;hex 09 which is tab&lt;/P&gt;
&lt;P&gt;hex 33 which is 3&lt;/P&gt;
&lt;P&gt;hex 32 which is 2&lt;/P&gt;
&lt;P&gt;hex 09 which is tab&lt;/P&gt;
&lt;P&gt;hex 33 which is 3&lt;/P&gt;
&lt;P&gt;hex 34 which is 4&lt;/P&gt;
&lt;P&gt;hex 20 which is space&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the whole field is read in on swoop and the result is not a number. Hence the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is a mix of space separated and tab separated numbers, you really need the source to give you a better file.&lt;/P&gt;
&lt;P&gt;If that's impossible, you can write code to parse the line for values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: In EG, you can replace all tabs in the code editor by using regular expression replacement:&lt;/P&gt;
&lt;DIV id="tinyMceEditorChrisNZ_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;[The image seems to be gone. Check the &lt;EM&gt;regular expression search&lt;/EM&gt; box, enter \x09 in the &lt;EM&gt;find text&lt;/EM&gt; field, enter a space in the &lt;EM&gt;replace with&lt;/EM&gt; field. ]&lt;/P&gt;
&lt;DIV id="tinyMceEditorChrisNZ_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;There is no reason tabs should ever be there.&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 01:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668746#M200514</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-14T01:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with input and datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668753#M200518</link>
      <description>&lt;P&gt;Your code &lt;EM&gt;as posted&lt;/EM&gt; &lt;U&gt;does&lt;/U&gt; work, but that may be because you (wrongly) posted the code into the main posting window, and it converted tabs to HTML white space (a single blank).&lt;/P&gt;
&lt;P&gt;Always use the "little running man" icon next to the one indicated for posting code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/E0BB18E7DAA53C21BC28740CEA0E38DA/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MySample1;
input Firstfield secondfield thirdfield;
datalines;
123 34 54
21 35 33
1 32 34
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Similarly, use the indicated icon (&amp;lt;/&amp;gt;) for logs or other structured text data.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 07:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-input-and-datalines/m-p/668753#M200518</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-13T07:36:26Z</dc:date>
    </item>
  </channel>
</rss>

