<?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: How to solve length problems? when it showed invalid data in line _ and N=option in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432641#M4511</link>
    <description>&lt;P&gt;One of the essential tools for importing text data is an editor that can display hex codes (ie notepad++). Using this, it is easy to see that your text file is tab-delimited, so you should approach it like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars93subtab;
infile '/folders/myfolders/cars93subtab.txt' dlm='09'x termstr=CRLF firstobs=2;
input Manufacturer :$10. Type :$10. Price MPG_city MPG_highway Horsepower Origin $;
run;

proc print data=cars93subtab;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Adjust lengths as needed.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jan 2018 09:17:40 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-01-31T09:17:40Z</dc:date>
    <item>
      <title>How to solve length problems? when it showed invalid data in line _ and N=option</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432584#M4508</link>
      <description>&lt;PRE&gt;data cars93subtab;
infile '/folders/myfolders/cars93subtab.txt' dlm=',' termstr=CRLF firstobs=2;
input Manufacturer $ Type $ Price MPG_city MPG_highway Horsepower Origin $;

run;
proc print data=cars93subtab;
run;&lt;/PRE&gt;&lt;P&gt;My output was only two rows and mainly missing data.&lt;/P&gt;&lt;P&gt;The log showed that "invalid data for ___ in line ___&lt;/P&gt;&lt;P&gt;and provided "n=option"&lt;/P&gt;&lt;P&gt;Can anybody tell me how to set up the length of variables?&lt;/P&gt;&lt;P&gt;I guess the reason was the setting of length of variables.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 01:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432584#M4508</guid>
      <dc:creator>jc3992</dc:creator>
      <dc:date>2018-01-31T01:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve length problems? when it showed invalid data in line _ and N=option</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432587#M4509</link>
      <description>&lt;P&gt;You specify the length ahead of the INPUT statement. The default length is 8.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data cars93subtab;
infile '/folders/myfolders/cars93subtab.txt' dlm=',' termstr=CRLF firstobs=2;&lt;BR /&gt;length manufacturer $30 Type $20;
input Manufacturer $ Type $ Price MPG_city MPG_highway Horsepower Origin $;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;A quick way to cheat to import your data is to use PROC IMPORT and then borrow the code from the log and adjust it. Or at least use it as a reference to determine how to set up your Formats/Informats and Lengths.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;file cars '/folders/myfolders/cars93subtab.txt' termstr=crlf;

proc import out=cars93subtab datafile=cars dbms=csv replace; 
getnames=yes;
guessingrows=max;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2018 02:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432587#M4509</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-31T02:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve length problems? when it showed invalid data in line _ and N=option</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432596#M4510</link>
      <description>&lt;P&gt;wow, there are many ways to write a code for the same question.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data cars93subtab;
infile '/folders/myfolders/cars93subtab.txt' termstr=CRLF firstobs=2;
length Manufacturer $10;
input Manufacturer $ Type $ Price MPG_city MPG_highway Horsepower Origin $;
run;

proc print data=cars93subtab;
run;

&lt;/PRE&gt;&lt;P&gt;when I checked the data in a text editor, I found there are many spaces between each variables,&lt;/P&gt;&lt;P&gt;I checked the text book, in this way, list input is not appropriate.&lt;/P&gt;&lt;P&gt;I used the above code to run it again, still did not work.&lt;/P&gt;&lt;P&gt;I shall use your code but I have to review my text book again.&lt;/P&gt;&lt;P&gt;Thank you:)&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 03:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432596#M4510</guid>
      <dc:creator>jc3992</dc:creator>
      <dc:date>2018-01-31T03:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve length problems? when it showed invalid data in line _ and N=option</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432641#M4511</link>
      <description>&lt;P&gt;One of the essential tools for importing text data is an editor that can display hex codes (ie notepad++). Using this, it is easy to see that your text file is tab-delimited, so you should approach it like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars93subtab;
infile '/folders/myfolders/cars93subtab.txt' dlm='09'x termstr=CRLF firstobs=2;
input Manufacturer :$10. Type :$10. Price MPG_city MPG_highway Horsepower Origin $;
run;

proc print data=cars93subtab;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Adjust lengths as needed.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 09:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432641#M4511</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-31T09:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve length problems? when it showed invalid data in line _ and N=option</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432800#M4515</link>
      <description>&lt;P&gt;Yeah, I just looked at your text file. Your code as DLM=',' but there's no comma's in the file&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 15:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-solve-length-problems-when-it-showed-invalid-data-in-line/m-p/432800#M4515</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-31T15:47:00Z</dc:date>
    </item>
  </channel>
</rss>

