<?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 csv files from local folder in work. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550060#M152701</link>
    <description>&lt;P&gt;You do not create macro variable file_name before you first use it (the select into that creates it follows later).&lt;/P&gt;</description>
    <pubDate>Wed, 10 Apr 2019 20:27:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-04-10T20:27:14Z</dc:date>
    <item>
      <title>Importing csv files from local folder in work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550034#M152692</link>
      <description>&lt;P&gt;Hello I am trying to import csv files in my work library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let directory = E:\saved ;&lt;/P&gt;&lt;P&gt;filename files pipe "dir /b &amp;amp;directory\*.csv";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data file_list;&lt;BR /&gt;length file_name $40;&lt;BR /&gt;infile files length=reclen;&lt;BR /&gt;input file_name $varying40. reclen;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro csv;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select count(*) into :vol_of_files&lt;BR /&gt;from work.file_list;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;vol_of_files.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.file_list_v2;&lt;BR /&gt;set work.file_list (firstobs = &amp;amp;i.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql outobs=1;&lt;BR /&gt;create table work.file_list_v3 as&lt;BR /&gt;select *&lt;BR /&gt;from work.file_list_v2;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select * into :file_name&lt;BR /&gt;from work.file_list_v3;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data file_list_v4 (keep=file_name_new);&lt;BR /&gt;set file_list_v3;&lt;BR /&gt;file_name_new = reverse(substr(reverse(&amp;amp;file_name.),5));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select * into :file_name_v2&lt;BR /&gt;from work.file_list_v4;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import out=&amp;amp;file_name_v2.&lt;BR /&gt;datafile="&amp;amp;directory.\&amp;amp;file_name."&lt;BR /&gt;dbms=csv replace;&lt;BR /&gt;getnames=yes;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%mend csv;&lt;BR /&gt;%csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea that I had, was to store the file names into a table file_list as values of a variable file_name.&lt;/P&gt;&lt;P&gt;Later I find the length of the table, and I want to iterate thought the values of this column. My logic gives an error and I am not sure.&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 18:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550034#M152692</guid>
      <dc:creator>Nikolasas</dc:creator>
      <dc:date>2019-04-10T18:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv files from local folder in work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550054#M152696</link>
      <description>&lt;P&gt;When you encounter an ERROR,&amp;nbsp;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; post the log, using the {i} button.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 19:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550054#M152696</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-10T19:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv files from local folder in work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550056#M152698</link>
      <description>&lt;P&gt;My bad. I thought I had done so.&lt;/P&gt;&lt;P&gt;Thanks for mentioning this.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 19:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550056#M152698</guid>
      <dc:creator>Nikolasas</dc:creator>
      <dc:date>2019-04-10T19:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv files from local folder in work.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550060#M152701</link>
      <description>&lt;P&gt;You do not create macro variable file_name before you first use it (the select into that creates it follows later).&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 20:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-files-from-local-folder-in-work/m-p/550060#M152701</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-10T20:27:14Z</dc:date>
    </item>
  </channel>
</rss>

