<?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: Truncating when reading in csv format data file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147570#M29250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amy_W,&lt;/P&gt;&lt;P&gt;This worked for me.&amp;nbsp; I added a delimeter statement and gave all the variables lengths.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data EOY_survey1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'E:\test.csv'&amp;nbsp; dsd delimiter=',' truncover nopad lrecl=600;&lt;BR /&gt;&amp;nbsp; length Test_Admin_Code Test_Code State District School PA_Unique_ID $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length Operating_System $150;&lt;BR /&gt;&amp;nbsp; length Clip_UIN $50 Survey_Item_UIN $50 Survey_Response $120;&lt;BR /&gt;&amp;nbsp; input Test_Admin_Code $ Test_Code $ State $ District $ School $ PA_Unique_ID $ Operating_System $ Clip_UIN $ Survey_Item_UIN $ Survey_Response $;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=EOY_survey1;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Aug 2014 15:31:10 GMT</pubDate>
    <dc:creator>jwillis</dc:creator>
    <dc:date>2014-08-04T15:31:10Z</dc:date>
    <item>
      <title>Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147566#M29246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a csv format data file that I'd like to read into SAS. Variables vary different length in the original data file. For example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"parfteoy","MAT04C2","MA","01010000","01010032","102309025","","00068023639805201406","MP09","1"&lt;/P&gt;&lt;P&gt;"parfteoy","MAT07C2","MA","01010000","01010310","102436546","Mozilla/5.0 (X11; CrOS x86_64 5500.130.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.134 Safari/537.36","AAAKK14142P000206919","MC01","A"&lt;/P&gt;&lt;P&gt;"parfteoy","MAT07C2","MA","01010000","01010310","102436546","Mozilla/5.0 (X11; CrOS x86_64 5500.130.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.134 Safari/537.36","AAAKK14142P000206919","MC18","Some of the questions I just didn't understand what it was asking me to do."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used data step to read in the file, and here is my codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data EOY_survey1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile '....EOY_AL.txt'&amp;nbsp; dsd missover lrecl=600;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input Test_Admin_Code $ Test_Code $ State $ District $ School $ PA_Unique_ID $ Operating_System $ Clip_UIN $ Survey_Item_UIN $ Survey_Response $;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No error messages but variables were truncated in Operating_System and Survey_Response. I have tried to set up the length but it worked only for Survey_Response, not for Operating_System. Could someone give me suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147566#M29246</guid>
      <dc:creator>Amy_W</dc:creator>
      <dc:date>2014-08-04T15:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147567#M29247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like all your variables being define with length $8&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add a length statement to define the length of the variables that need to be longer than 8 bytes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147567#M29247</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-08-04T15:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147568#M29248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, two things:&lt;/P&gt;&lt;P&gt;data eoy_survey1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrib&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test_admin_code test_code ... format=$2000.;&amp;nbsp; /* If you don't attrib or length first then these get defaulted to char(8) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile ... dlm="," lrecl=32000; /* Update to be longer it doesn't hurt, also I like specifying the delimiter, though it shouldn't matter */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input xyz $...;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147568#M29248</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-04T15:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147569#M29249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attrib statment worked but not the length statement. I will dig more. Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147569#M29249</guid>
      <dc:creator>Amy_W</dc:creator>
      <dc:date>2014-08-04T15:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147570#M29250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amy_W,&lt;/P&gt;&lt;P&gt;This worked for me.&amp;nbsp; I added a delimeter statement and gave all the variables lengths.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data EOY_survey1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'E:\test.csv'&amp;nbsp; dsd delimiter=',' truncover nopad lrecl=600;&lt;BR /&gt;&amp;nbsp; length Test_Admin_Code Test_Code State District School PA_Unique_ID $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length Operating_System $150;&lt;BR /&gt;&amp;nbsp; length Clip_UIN $50 Survey_Item_UIN $50 Survey_Response $120;&lt;BR /&gt;&amp;nbsp; input Test_Admin_Code $ Test_Code $ State $ District $ School $ PA_Unique_ID $ Operating_System $ Clip_UIN $ Survey_Item_UIN $ Survey_Response $;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=EOY_survey1;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147570#M29250</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-08-04T15:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147571#M29251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks jwillis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the length statement at the very beginning to specify &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Operating_System&lt;/SPAN&gt; and &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Survey_Response&lt;/SPAN&gt; only. However, variables after &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Operating_System&lt;/SPAN&gt; were all missing. I didn't try specify length to every variable. Maybe that's the problem. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147571#M29251</guid>
      <dc:creator>Amy_W</dc:creator>
      <dc:date>2014-08-04T15:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147572#M29252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would not use a FORMAT to imply length in this way, it makes it look like you don't know what you're doing.&amp;nbsp; I usually prefer that character variables not have simple $Fnnn. format associated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147572#M29252</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-08-04T15:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating when reading in csv format data file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147573#M29253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if you specify a length it will be assigned a $ format of that length by default.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 16:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncating-when-reading-in-csv-format-data-file/m-p/147573#M29253</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-08-04T16:41:13Z</dc:date>
    </item>
  </channel>
</rss>

