<?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: INFILE not reading last column (numeric variable) of csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868975#M343283</link>
    <description>&lt;P&gt;PROC IMPORT uses DATA step code behind the scenes. Check your SAS log to see if it shows up or not. If not try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options source;

proc import etc....;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Apr 2023 03:42:46 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2023-04-11T03:42:46Z</dc:date>
    <item>
      <title>INFILE not reading last column (numeric variable) of csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868973#M343282</link>
      <description>&lt;P&gt;I'm at my wit's end. I'm trying to read in a .csv file in a SAS data step. The last column of the file, a numeric variable, is showing up as all missing values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The .csv file was created in a Windows environment. I'm working in Windows on SAS Enterprise Guide 7.15. Here're a few lines of the SAS file:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;monyear&lt;/TD&gt;&lt;TD&gt;patcounty&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;TD&gt;tot_mme&lt;/TD&gt;&lt;TD&gt;highmme&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16-Jan&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;70253&lt;/TD&gt;&lt;TD&gt;64753813&lt;/TD&gt;&lt;TD&gt;6369&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16-Jan&lt;/TD&gt;&lt;TD&gt;B&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;26797.5&lt;/TD&gt;&lt;TD&gt;6827&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16-Jan&lt;/TD&gt;&lt;TD&gt;C&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3471&lt;/TD&gt;&lt;TD&gt;4238297&lt;/TD&gt;&lt;TD&gt;388&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16-Jan&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;25693&lt;/TD&gt;&lt;TD&gt;33292887&lt;/TD&gt;&lt;TD&gt;3006&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;16-Jan&lt;/TD&gt;&lt;TD&gt;E&lt;/TD&gt;&lt;TD&gt;4505&lt;/TD&gt;&lt;TD&gt;6134380&lt;/TD&gt;&lt;TD&gt;550&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here's my code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.ucd2 (keep=monyear year patcounty count tot_mme highmme);
	retain monyear year patcounty count tot_mme highmme; 
	infile "G:\SAPB\Projects\OD2A\Evaluation\UCD Evaluation\Data\ucd_cures2.csv"
	dlm = ","
	firstobs=2
	truncover
	termstr=crlf;
	
	input monyear $
		patcounty $
		count
		tot_mme
		highmme;    
	
	year2 = "20"||trim(substr(monyear,1,2));
	year = input(year2, 4.);
	put year=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And here's what the code spits out:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dbcrow_0-1681183325067.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82457iB674E93EBEAD7494/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dbcrow_0-1681183325067.png" alt="dbcrow_0-1681183325067.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've tried different values in the "termstr" option ("cr", "lf", "crlf"); used or omitted, variously, the "truncover", "missover", and "dsd" options; and tried this solution:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched high and low, including in SAS user forums and StackExchange, but nothing works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FWIW, PROC IMPORT reads the .csv file in just fine. But there must be some way to do this in a data step.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 03:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868973#M343282</guid>
      <dc:creator>dbcrow</dc:creator>
      <dc:date>2023-04-11T03:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE not reading last column (numeric variable) of csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868975#M343283</link>
      <description>&lt;P&gt;PROC IMPORT uses DATA step code behind the scenes. Check your SAS log to see if it shows up or not. If not try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options source;

proc import etc....;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2023 03:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868975#M343283</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-04-11T03:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE not reading last column (numeric variable) of csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868985#M343286</link>
      <description>&lt;P&gt;Many thanks, SASKiwi. The DATA step did show up in the log. I copied and pasted the relevant lines, adding the LRECL=32767 option and putting in the INFORMAT, FORMAT, and INPUT statements as indicated in the log.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All to no avail. I'm still getting the missing values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are a few lines from the log after running the DATA step (with county names redacted):&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dbcrow_0-1681187779905.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82465iE706A2D18213FF50/image-size/large?v=v2&amp;amp;px=999" role="button" title="dbcrow_0-1681187779905.png" alt="dbcrow_0-1681187779905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Somehow, some extraneous numbers are added to the end of each line. For example, record #2 has the value 6369 in the variable "highmme", but adds "68" to the value. Similarly, record #3 has the value of 5 for "highmme", but adds "48" at the end.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what's going on? Is it related to the problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 04:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868985#M343286</guid>
      <dc:creator>dbcrow</dc:creator>
      <dc:date>2023-04-11T04:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE not reading last column (numeric variable) of csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868991#M343288</link>
      <description>&lt;P&gt;Your INPUT statement contains 5 variables, but the log shows 9 comma-separated columns, the 5th of which (which would be highmme) you blacked out.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 05:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868991#M343288</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-11T05:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE not reading last column (numeric variable) of csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868995#M343289</link>
      <description>&lt;P&gt;Bingo!&amp;nbsp; And ... duh.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to both of you, SASKiwi and Kurt_Bremser, for taking the time to respond. SASKiwi: I'm sorry I can only select one response as the solution. Looking in the log at what INFILE does with the behind-the-scenes DATA step was fantastic information, but Kurt_Bremer's solution more directly aided me in solving my problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 05:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-not-reading-last-column-numeric-variable-of-csv-file/m-p/868995#M343289</guid>
      <dc:creator>dbcrow</dc:creator>
      <dc:date>2023-04-11T05:47:23Z</dc:date>
    </item>
  </channel>
</rss>

