<?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 Exporting multiple CSV files from SAS EG local machine in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/334002#M22203</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I installed a DLL file to facilitate the importing/exporting of any files from SAS EG to my local machine and vice versa. Specifically, I'm trying to export mutliple CSV files from a desginated SAS library to different folders on one of my local drives. I developed a macro that successfully builds each of the CSV files needed for the Export Task (I created my own task template...see attached). However, the problem I am encountering is that when I go to run the Export Task, instead of processing all the files, it processes only the last file built from the macro, thereby rendering the macro useless. Is there a way for me to export all files (in this case 4) from the library using the Export Task in one go? I appreciate any help or insight on this. Below is my macro code and I've attached a screen shot of my custom Task Template. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro csv_export (st,aco,datafile);&lt;BR /&gt;/* Data to export */&lt;BR /&gt;%let lib = TEST;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select memname&lt;BR /&gt;into : datafile1 - : datafile4&lt;BR /&gt;from sashelp.vmember&lt;BR /&gt;where libname = "TEST";&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Local folder to download to */&lt;BR /&gt;%let download_to = E:\AA_AU_Monthly_Runs\AA_AU 2017\AA_AU_2017_03_Mar\Step_100_Roster_Prep\&amp;amp;st\&amp;amp;aco ;&lt;BR /&gt;&lt;BR /&gt;/* detect proper delim for UNIX vs. Windows */&lt;BR /&gt;%let delim=%sysfunc(ifc(%eval(&amp;amp;sysscp. = WIN),\,/));&lt;BR /&gt;&lt;BR /&gt;%let download_from =&lt;BR /&gt;%sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile...csv;&lt;BR /&gt;&lt;BR /&gt;filename src "&amp;amp;download_from.";&lt;BR /&gt;&lt;BR /&gt;proc export data=&amp;amp;lib..&amp;amp;datafile.&lt;BR /&gt;dbms=csv&lt;BR /&gt;file=src&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;filename src clear;&lt;/P&gt;&lt;P&gt;%mend csv_export;&lt;/P&gt;&lt;P&gt;%csv_export(TX,ADV,&amp;amp;datafile1);&lt;BR /&gt;%csv_export(TX,ADV,&amp;amp;datafile2);&lt;BR /&gt;%csv_export(IL,LURIE,&amp;amp;datafile3);&lt;BR /&gt;%csv_export(IL,LURIE,&amp;amp;datafile4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13459iFC2CC07E7913D84A/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="csv_task_template.PNG" title="csv_task_template.PNG" /&gt;</description>
    <pubDate>Fri, 17 Feb 2017 23:50:18 GMT</pubDate>
    <dc:creator>JT1</dc:creator>
    <dc:date>2017-02-17T23:50:18Z</dc:date>
    <item>
      <title>Exporting multiple CSV files from SAS EG local machine</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/334002#M22203</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I installed a DLL file to facilitate the importing/exporting of any files from SAS EG to my local machine and vice versa. Specifically, I'm trying to export mutliple CSV files from a desginated SAS library to different folders on one of my local drives. I developed a macro that successfully builds each of the CSV files needed for the Export Task (I created my own task template...see attached). However, the problem I am encountering is that when I go to run the Export Task, instead of processing all the files, it processes only the last file built from the macro, thereby rendering the macro useless. Is there a way for me to export all files (in this case 4) from the library using the Export Task in one go? I appreciate any help or insight on this. Below is my macro code and I've attached a screen shot of my custom Task Template. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro csv_export (st,aco,datafile);&lt;BR /&gt;/* Data to export */&lt;BR /&gt;%let lib = TEST;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select memname&lt;BR /&gt;into : datafile1 - : datafile4&lt;BR /&gt;from sashelp.vmember&lt;BR /&gt;where libname = "TEST";&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Local folder to download to */&lt;BR /&gt;%let download_to = E:\AA_AU_Monthly_Runs\AA_AU 2017\AA_AU_2017_03_Mar\Step_100_Roster_Prep\&amp;amp;st\&amp;amp;aco ;&lt;BR /&gt;&lt;BR /&gt;/* detect proper delim for UNIX vs. Windows */&lt;BR /&gt;%let delim=%sysfunc(ifc(%eval(&amp;amp;sysscp. = WIN),\,/));&lt;BR /&gt;&lt;BR /&gt;%let download_from =&lt;BR /&gt;%sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile...csv;&lt;BR /&gt;&lt;BR /&gt;filename src "&amp;amp;download_from.";&lt;BR /&gt;&lt;BR /&gt;proc export data=&amp;amp;lib..&amp;amp;datafile.&lt;BR /&gt;dbms=csv&lt;BR /&gt;file=src&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;filename src clear;&lt;/P&gt;&lt;P&gt;%mend csv_export;&lt;/P&gt;&lt;P&gt;%csv_export(TX,ADV,&amp;amp;datafile1);&lt;BR /&gt;%csv_export(TX,ADV,&amp;amp;datafile2);&lt;BR /&gt;%csv_export(IL,LURIE,&amp;amp;datafile3);&lt;BR /&gt;%csv_export(IL,LURIE,&amp;amp;datafile4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13459iFC2CC07E7913D84A/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="csv_task_template.PNG" title="csv_task_template.PNG" /&gt;</description>
      <pubDate>Fri, 17 Feb 2017 23:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/334002#M22203</guid>
      <dc:creator>JT1</dc:creator>
      <dc:date>2017-02-17T23:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple CSV files from SAS EG local machine</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/334985#M22267</link>
      <description>&lt;P&gt;JT1,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problems lies in the following SAS statement:&lt;/P&gt;
&lt;PRE&gt;%let download_from =
%sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile...csv;
&lt;/PRE&gt;
&lt;P&gt;which points to a single file, and gets overwritten by each macro call. My solution, however, depends on your CSV filenames being the only CSV files present in a&amp;nbsp;&amp;amp;download_from folder:&lt;/P&gt;
&lt;PRE&gt;%let download_from =
%sysfunc(getoption(work));&lt;BR /&gt;
filename src "&amp;amp;download_from.&lt;FONT color="#FF0000"&gt;&amp;amp;delim.&amp;amp;datafile...csv&lt;/FONT&gt;";&lt;/PRE&gt;
&lt;P&gt;You should then be able to use the following text in the Source files box:&lt;/P&gt;
&lt;PRE&gt;&amp;amp;download_from.&amp;amp;delim.*.csv&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Hope this makes sense...........Phil&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 15:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/334985#M22267</guid>
      <dc:creator>hollandnumerics</dc:creator>
      <dc:date>2017-02-22T15:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple CSV files from SAS EG local machine</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/335111#M22276</link>
      <description>&lt;P&gt;Phil,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response! It certainly makes sense and I made your suggested changes. However, when I run the task, I am now receiving the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Target folder (&amp;amp;download_to.) does not exist or cannot be accessed on LOKN3DDS (this is the name of my local machine).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran it again with my old code and got the same error so I doubt it has anything to do with the modifications but puzzled as to why this error is showing up now and not prior.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Jared&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 20:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/335111#M22276</guid>
      <dc:creator>JT1</dc:creator>
      <dc:date>2017-02-22T20:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple CSV files from SAS EG local machine</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/335267#M22279</link>
      <description>&lt;P&gt;Jt1,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you are being impacted by macro variable "scope", because, unless you have defined both &amp;amp;download_from and &amp;amp;download_to outside of the macro, it won't exist outside. Therefore I suggest you add a single statement at the top of your program outside of the macro to make sure the macro variables are available everywhere:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%GLOBAL download_from download_to;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;..............Phil&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 12:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/335267#M22279</guid>
      <dc:creator>hollandnumerics</dc:creator>
      <dc:date>2017-02-23T12:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple CSV files from SAS EG local machine</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/336423#M22363</link>
      <description>&lt;P&gt;Hollandnumerics,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added in the %GLOBAL download_from download_to. However, now I am receiving a different type of error. Specifically....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Download exception occurred. &amp;lt;?xml version="1.0" ?&amp;gt;&amp;lt;Exceptions&amp;gt;&amp;lt;Exception&amp;gt;&amp;lt;SASMessage severity="Error"&amp;gt;Invalid file, /SASWork/SAS_work064400005256_pwauslsasgap09/SAS_work386F00005256_pwauslsasgap09.&amp;lt;/SASMessage&amp;gt;&amp;lt;/Exception&amp;gt;&amp;lt;/Exceptions&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jared&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 02:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/336423#M22363</guid>
      <dc:creator>JT1</dc:creator>
      <dc:date>2017-02-28T02:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting multiple CSV files from SAS EG local machine</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/336492#M22367</link>
      <description>&lt;P&gt;Jared,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see 2 copies of the WORK folder (/SASWork/SAS_work064400005256_pwauslsasgap09) in the error message. I would look at what you are actually providing to the EG Task in &amp;amp;download_from and &amp;amp;download_to, because I don't think what you have in &amp;amp;download_from.&amp;amp;delim.*.csv is "&lt;EM&gt;folder&lt;/EM&gt;/*.csv".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.............Phil&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 10:22:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Exporting-multiple-CSV-files-from-SAS-EG-local-machine/m-p/336492#M22367</guid>
      <dc:creator>hollandnumerics</dc:creator>
      <dc:date>2017-02-28T10:22:20Z</dc:date>
    </item>
  </channel>
</rss>

