<?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 from Text file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333658#M75228</link>
    <description>&lt;PRE&gt;
1)Try Arthur.T 's code and add one more  option.

data want;
  infile '/folders/myfolders/have.txt' firstobs=3 expandtabs;
  informat Student_ID $8.;
  informat Call_ID $17.;
  input Student_ID Call_ID;
run;


2)Try another engine.

proc import datafile='R:\have.txt'
            out=test
            dbms=tab
            replace;
	      
run;
&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 Feb 2017 01:59:14 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-02-17T01:59:14Z</dc:date>
    <item>
      <title>Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333568#M75192</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Student_ID                     Call_ID

09008767                       02541-027-0415471                                                                            
09149065                       04531-027-8565478                                                                            
09597360                       04531-027-2546587 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have the&amp;nbsp;above table in a .txt file. I want to import as sas dataset. My following code is not working. Can someone help me please. Please note that there are 23 character space between first two values and 14 space between 2nd and 3rd value (I have 9 variables total in the dataset). I am getting the following error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The quoted string currently being processed has become more than 262 characters long. You&lt;BR /&gt; might have unbalanced quotation marks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='R:\have.txt'
            out=test
            dbms=dlm
            replace;
	        delimiter='09'x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333568#M75192</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2017-02-16T20:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333573#M75193</link>
      <description>&lt;P&gt;If there are spaces between the two fields, why are you using a tab ('09'x) as the delimiter?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333573#M75193</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-02-16T20:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333574#M75194</link>
      <description>What should I use collinelliot?</description>
      <pubDate>Thu, 16 Feb 2017 20:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333574#M75194</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2017-02-16T20:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333576#M75195</link>
      <description>&lt;P&gt;Use a data step instead, something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fileref 'filepath';

data test;
   infile fileref;
   input student_id 1-8 call_id $ 32-48;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that blank row is there, you could add a 'if _n_&amp;lt;=2 then delete;'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333576#M75195</guid>
      <dc:creator>cau83</dc:creator>
      <dc:date>2017-02-16T20:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333577#M75196</link>
      <description>&lt;P&gt;Or, rather than worrying about the specific column locations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  infile '/folders/myfolders/have.txt' firstobs=3;
  informat Student_ID $8.;
  informat Call_ID $17.;
  input Student_ID Call_ID;
run;&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333577#M75196</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-16T20:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333581#M75199</link>
      <description>&lt;P&gt;I just noticed that each of my variable has different lengths with different space length in between. Is there a way I can import them without defining the character space. Like something that we do in imorting from Excel?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333581#M75199</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2017-02-16T20:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333582#M75200</link>
      <description>&lt;P&gt;See my post above. Just make sure that the lengths set in the informats are long enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333582#M75200</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-16T20:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333585#M75202</link>
      <description>&lt;P&gt;Depending on the variability... sometimes I cave and bring it all in as one giant field and then split with data step functions. For instance, if sometimes the first column value length is so long that it spills over to what is sometimes the 2nd column, then even specifying lengths on the informat isn't foolproof. So instead I (not saying it's the best way, just the crutch iI go to):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile;
  input BIG_VAR $ 1-250;

   var1=strip(scan(big_var,1," "));
   var2=strip(scan(big_var,2," "));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming that there are no spaces within the fields, this should split it up and then the strip function will get rid of the leading/trailing blanks I believe.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 21:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333585#M75202</guid>
      <dc:creator>cau83</dc:creator>
      <dc:date>2017-02-16T21:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333658#M75228</link>
      <description>&lt;PRE&gt;
1)Try Arthur.T 's code and add one more  option.

data want;
  infile '/folders/myfolders/have.txt' firstobs=3 expandtabs;
  informat Student_ID $8.;
  informat Call_ID $17.;
  input Student_ID Call_ID;
run;


2)Try another engine.

proc import datafile='R:\have.txt'
            out=test
            dbms=tab
            replace;
	      
run;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 01:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333658#M75228</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-02-17T01:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Importing from Text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333738#M75254</link>
      <description>&lt;P&gt;Why use proc import at all with such an easy structure?&lt;/P&gt;
&lt;P&gt;I copy/pasted your text data into a UNIX text file and ran the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile '$HOME/sascommunity/test.txt' firstobs=3;
length student_id $8 call_id $17;
input student_id call_id;
run;

proc print data=test noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is the result:&lt;/P&gt;
&lt;PRE&gt;student_
   id            call_id

09008767    02541-027-0415471
09149065    04531-027-8565478
09597360    04531-027-2546587
&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 11:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-from-Text-file/m-p/333738#M75254</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-17T11:03:11Z</dc:date>
    </item>
  </channel>
</rss>

