<?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: Importing txt file in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698935#M25565</link>
    <description>&lt;P&gt;First of all, the import seems to have worked, but it is a very good idea to get rid of all those pesky NOTEs that contain the string ERROR.&lt;/P&gt;
&lt;P&gt;Your import did work because the NOTEs are caused by strings NA where you expect a number, and we can quite safely infer that NA should result in a missing number.&lt;/P&gt;
&lt;P&gt;I recommend to use a dedicated informat:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue na
  'NA' = .
  other = [best.]
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This custom informat reacts specifically to the string NA, and uses the default informat BEST for anything else.&lt;/P&gt;
&lt;P&gt;And then write the data step yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile "yourfile" dlm='09'x dsd truncover firstobs=2;
input
  sl_no
  school
  iq
  test
  ses
  class_size :na.
  meanses
  meaniq
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, the data step is not complicated at all. For delimited text files, PROC IMPORT is not needed, you can write the step directly from the file documentation, and it will give you consistent results. If IMPORT had checked the file a little more, your column class_size would have ended up as character, something you would not want.&lt;/P&gt;</description>
    <pubDate>Sun, 15 Nov 2020 06:19:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-11-15T06:19:10Z</dc:date>
    <item>
      <title>Importing txt file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698934#M25564</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT DATAFILE= '/home/u44418748/MSc Biostatistics with SAS/Datasets/school.txt' 
OUT= outdata 
DBMS=dlm 
REPLACE; 
delimiter='09'x;
GETNAMES=YES; 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used the above code to import txt file in sas&lt;/P&gt;
&lt;P&gt;But i got SAS log as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: Invalid data for class_size in line 454 17-18.&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="sasSource"&gt;454 CHAR 453.34.11.31.15.NA.23.125.12.188 32&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;ZONE 33303303303303304403323330332333&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;NUMR 4539349119319159E1923E125912E188&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;sl_no=453 school=34 iq=11 test=31 ses=15 class_size=. meanses=23.125 meaniq=12.188 _ERROR_=1 _N_=453&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;because class size is .&amp;nbsp; this is just one part of log&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;i have many missing value as .&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;how can i import data sucessfully&lt;/DIV&gt;</description>
      <pubDate>Sun, 15 Nov 2020 06:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698934#M25564</guid>
      <dc:creator>satishih77</dc:creator>
      <dc:date>2020-11-15T06:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Importing txt file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698935#M25565</link>
      <description>&lt;P&gt;First of all, the import seems to have worked, but it is a very good idea to get rid of all those pesky NOTEs that contain the string ERROR.&lt;/P&gt;
&lt;P&gt;Your import did work because the NOTEs are caused by strings NA where you expect a number, and we can quite safely infer that NA should result in a missing number.&lt;/P&gt;
&lt;P&gt;I recommend to use a dedicated informat:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue na
  'NA' = .
  other = [best.]
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This custom informat reacts specifically to the string NA, and uses the default informat BEST for anything else.&lt;/P&gt;
&lt;P&gt;And then write the data step yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile "yourfile" dlm='09'x dsd truncover firstobs=2;
input
  sl_no
  school
  iq
  test
  ses
  class_size :na.
  meanses
  meaniq
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, the data step is not complicated at all. For delimited text files, PROC IMPORT is not needed, you can write the step directly from the file documentation, and it will give you consistent results. If IMPORT had checked the file a little more, your column class_size would have ended up as character, something you would not want.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Nov 2020 06:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698935#M25565</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-15T06:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing txt file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698943#M25566</link>
      <description>Add an option :&lt;BR /&gt;&lt;BR /&gt;guessingrows=max ;</description>
      <pubDate>Sun, 15 Nov 2020 10:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-txt-file/m-p/698943#M25566</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-11-15T10:51:31Z</dc:date>
    </item>
  </channel>
</rss>

