<?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: Data trimmed while importing multiple csv files in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431108#M68652</link>
    <description>&lt;P&gt;Add the GUESSINGROWS=MAX option - it will take longer to run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or write a data step that explicitly defines the length and type.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2018 21:32:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-25T21:32:02Z</dc:date>
    <item>
      <title>Data trimmed while importing multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431107#M68651</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot (6).png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18109i2E591B4349449C5C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (6).png" alt="Screenshot (6).png" /&gt;&lt;/span&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used the following code and macro to import mutliple csv files:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let path = C:\;&lt;/P&gt;&lt;P&gt;filename folder "&amp;amp;path\ndakota0711";&lt;/P&gt;&lt;P&gt;libname c 'C:\Temp';&lt;/P&gt;&lt;P&gt;options validmemname=extend;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; county_list;&lt;/P&gt;&lt;P&gt;length Line &lt;STRONG&gt;8&lt;/STRONG&gt; county_code $&lt;STRONG&gt;20&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;list = dopen('folder');&lt;/P&gt;&lt;P&gt;do Line = &lt;STRONG&gt;1&lt;/STRONG&gt; to dnum(List);&lt;/P&gt;&lt;P&gt;County_code = trim(dread(List,Line));&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop List Line;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; nd0711;&lt;/P&gt;&lt;P&gt;set county_list end=final;&lt;/P&gt;&lt;P&gt;call symputx(cats('County_Code', _N_), trim(County_Code));&lt;/P&gt;&lt;P&gt;call symputx(cats('Name', _N_), trim(nliteral(substr(County_Code,&lt;STRONG&gt;1&lt;/STRONG&gt;,min(&lt;STRONG&gt;32&lt;/STRONG&gt;, length(County_Code)-&lt;STRONG&gt;4&lt;/STRONG&gt;)))));&lt;/P&gt;&lt;P&gt;if final then call symputx(trim('Total'), _N_);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt; &lt;STRONG&gt;&lt;EM&gt;loop&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%do i = &lt;STRONG&gt;1&lt;/STRONG&gt; %to &amp;amp;Total;&lt;/P&gt;&lt;P&gt;proc import datafile="&amp;amp;path\ndakota0711\&amp;amp;&amp;amp;County_Code&amp;amp;i"&lt;/P&gt;&lt;P&gt;out=c.&amp;amp;&amp;amp;name&amp;amp;i&lt;/P&gt;&lt;P&gt;dbms=csv&lt;/P&gt;&lt;P&gt;replace;&lt;/P&gt;&lt;P&gt;getnames=yes;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt; loop;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;EM&gt;loop&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;However, observations of the first variable "From" in all imported data sets are all trimmed or truncated (I have attached a screenshot of the output file). Can anyone help me with this.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 21:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431107#M68651</guid>
      <dc:creator>abubakrayesh</dc:creator>
      <dc:date>2018-01-25T21:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Data trimmed while importing multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431108#M68652</link>
      <description>&lt;P&gt;Add the GUESSINGROWS=MAX option - it will take longer to run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or write a data step that explicitly defines the length and type.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 21:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431108#M68652</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-25T21:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data trimmed while importing multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431109#M68653</link>
      <description>Can you tell me where to insert the data step exactly? I am new to SAS and&lt;BR /&gt;not very comfortable with it yet. Thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Jan 2018 21:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431109#M68653</guid>
      <dc:creator>abubakrayesh</dc:creator>
      <dc:date>2018-01-25T21:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Data trimmed while importing multiple csv files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431110#M68654</link>
      <description>&lt;P&gt;When you run PROC IMPORT, check your log. It has the data step to import the code. Modify the lengths/types in that code to be what you want and then use that code to import the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This assumes all your data sets have the same type/format. If that's the case you can also follow the approach outlined here to import all at once into the same data set.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188982"&gt;@abubakrayesh&lt;/a&gt; wrote:&lt;BR /&gt;Can you tell me where to insert the data step exactly? I am new to SAS and&lt;BR /&gt;not very comfortable with it yet. Thanks.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 21:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-trimmed-while-importing-multiple-csv-files/m-p/431110#M68654</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-25T21:48:22Z</dc:date>
    </item>
  </channel>
</rss>

