<?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 Trying to read in a two variable file using INFILE but can't get it to work... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386345#M92505</link>
    <description>&lt;P&gt;Hello: Very new to SAS here. Tried searching the support community already but I'm on information overload. I'm trying to read in the attached text tab delimited file as a data set in SAS. The first field should be read in as a date, second as a number with one decimal place. Sample file attached. The code I'm running is not working. This is the code I'm trying to use...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SAData;
	infile 'D:\qsilver\Sas Data\NSAPur.txt' delimiter='	';
	input
	datefield mmddyy10.
	purindex
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Aug 2017 17:26:55 GMT</pubDate>
    <dc:creator>bzubrick</dc:creator>
    <dc:date>2017-08-08T17:26:55Z</dc:date>
    <item>
      <title>Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386345#M92505</link>
      <description>&lt;P&gt;Hello: Very new to SAS here. Tried searching the support community already but I'm on information overload. I'm trying to read in the attached text tab delimited file as a data set in SAS. The first field should be read in as a date, second as a number with one decimal place. Sample file attached. The code I'm running is not working. This is the code I'm trying to use...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SAData;
	infile 'D:\qsilver\Sas Data\NSAPur.txt' delimiter='	';
	input
	datefield mmddyy10.
	purindex
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386345#M92505</guid>
      <dc:creator>bzubrick</dc:creator>
      <dc:date>2017-08-08T17:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386347#M92506</link>
      <description>&lt;P&gt;should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data SAData;&lt;BR /&gt;infile 'D:\qsilver\Sas Data\NSAPur.txt' delimiter=' ';&lt;BR /&gt;input&lt;BR /&gt;&lt;STRONG&gt;datefield :mmddyy10.&lt;/STRONG&gt;&lt;BR /&gt;purindex&lt;/P&gt;&lt;P&gt;format&amp;nbsp;&lt;STRONG&gt;datefield&lt;SPAN&gt;&amp;nbsp;mmddyy10.;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386347#M92506</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-08T17:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386352#M92508</link>
      <description>&lt;P&gt;I tried your code but it's not reading in properly... I've attached a screenshot of the log output and the output dataset for you to see..&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data.png" style="width: 372px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14377i6E59C7B520EE948A/image-size/large?v=v2&amp;amp;px=999" role="button" title="data.png" alt="data.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="log.png" style="width: 572px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14378i3D4B260DC8A0C990/image-size/large?v=v2&amp;amp;px=999" role="button" title="log.png" alt="log.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386352#M92508</guid>
      <dc:creator>bzubrick</dc:creator>
      <dc:date>2017-08-08T17:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386353#M92509</link>
      <description>&lt;P&gt;Wait you made an edit to your original post and i'm getting a different error message and output format....still not working tho&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:37:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386353#M92509</guid>
      <dc:creator>bzubrick</dc:creator>
      <dc:date>2017-08-08T17:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386357#M92511</link>
      <description>&lt;P&gt;data SAData;&lt;BR /&gt;&lt;STRONG&gt;infile 'C:\Users\NSRINIV2\Desktop\NSAPurSample.txt' expandtabs truncover;&lt;/STRONG&gt;&lt;BR /&gt;input datefield : mmddyy10. purindex ;&lt;/P&gt;&lt;P&gt;format datefield mmddyy10.;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello mate!, Your file data is tab delimited in the first place. Kindly check and run the above&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my log:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: The infile 'C:\Users\NSRINIV2\Desktop\NSAPurSample.txt' is:&lt;BR /&gt;Filename=C:\Users\NSRINIV2\Desktop\NSAPurSample.txt,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=110,&lt;BR /&gt;Last Modified=08Aug2017:12:35:10,&lt;BR /&gt;Create Time=08Aug2017:12:35:10&lt;/P&gt;&lt;P&gt;NOTE: 7 records were read from the infile 'C:\Users\NSRINIV2\Desktop\NSAPurSample.txt'.&lt;BR /&gt;The minimum record length was 13.&lt;BR /&gt;The maximum record length was 15.&lt;BR /&gt;NOTE: The data set WORK.SADATA has 7 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386357#M92511</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-08T17:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386359#M92513</link>
      <description>&lt;P&gt;Ok this code is working for me. Thank you! Few follow up questions -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Why do you need the format statement... (below in bold/underline)? Shouldn't defining the data type as mmddyy10. in the input statement take care of the format?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Why did you use expandtabs instead of delimiter=' &amp;nbsp; '?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) What is truncover?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data SAData;&lt;BR /&gt;infile 'D:\qsilver\Sas Data\NSAPur.txt' expandtabs truncover;&lt;BR /&gt;input datefield : mmddyy10. purindex ;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;format datefield mmddyy10.;&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 18:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386359#M92513</guid>
      <dc:creator>bzubrick</dc:creator>
      <dc:date>2017-08-08T18:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386361#M92515</link>
      <description>&lt;P&gt;Ok this code is working for me. Thank you! Few follow up questions -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Why do you need the format statement... (below in bold/underline)? Shouldn't defining the data type as mmddyy10. in the input statement take care of the format?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The format in the input statement is actually an &lt;STRONG&gt;informat&lt;/STRONG&gt; that reads and converts non standard data like your character date to a SAS date value which is merely a number. This number has to be rerepresented as a character date for which you need a format statement.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Always remember&lt;/STRONG&gt;: Informat is to read and format is to write. They look the same yet they are different&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Why did you use expandtabs instead of delimiter=' &amp;nbsp; '?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I was lazy at first to have noticed your data delimited to blank at face value. But in reality when i actually moved my cursor I learned that it was actually tab delimited perhaps a copy paste from excel. If it's tab demilited you can't quite use dlm=' ' instead you need expandtabs or something dlm='2008'x it's blank and tab delimited--&amp;gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;the genius taught me this a couple of years ago&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) What is truncover?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Basically reads variable length records and doesn't jump to the next record and start reading &amp;nbsp;new values. Chill, in your data i don't see missing values, so this shouldn't affect the execution&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data SAData;&lt;BR /&gt;infile 'D:\qsilver\Sas Data\NSAPur.txt' expandtabs truncover;&lt;BR /&gt;input datefield : mmddyy10. purindex ;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;format datefield mmddyy10.;&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 18:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386361#M92515</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-08T18:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386362#M92516</link>
      <description>Thank you for all the follow up info!</description>
      <pubDate>Tue, 08 Aug 2017 18:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386362#M92516</guid>
      <dc:creator>bzubrick</dc:creator>
      <dc:date>2017-08-08T18:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386398#M92534</link>
      <description>&lt;P&gt;A minor addition about the DLM= on infile. DLM uses single characters. You may have data where your values are separated by spaces&amp;nbsp;or commas and you could use DLM=' ,' . to read&lt;/P&gt;
&lt;P&gt;123 John,Smith,"Some other text"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a longer string of characters as a delimiter that is always present you would use the DLMSTR option instead. If you data were separated by *x* then DLMSTR='*x*' would be used to read data that looks like&lt;/P&gt;
&lt;P&gt;123*x*John*x*Smith*x*Some other text&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 20:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386398#M92534</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-08T20:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to read in a two variable file using INFILE but can't get it to work...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386610#M92630</link>
      <description>Helpful, thanks!</description>
      <pubDate>Wed, 09 Aug 2017 13:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-read-in-a-two-variable-file-using-INFILE-but-can-t-get/m-p/386610#M92630</guid>
      <dc:creator>bzubrick</dc:creator>
      <dc:date>2017-08-09T13:28:26Z</dc:date>
    </item>
  </channel>
</rss>

