<?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: Getting the file name from importting wizard in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/420097#M27019</link>
    <description>&lt;P&gt;I think that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has the best suggestion.&amp;nbsp; As far as I know, the Import Data task does not place the imported file name into any macro or environment variable, so there isn't a way to pull that detail from the wizard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, you could adjust your process to upload the text file to SAS, then run a SAS program node to complete the import.&amp;nbsp; The upload process would need to use the Copy Files task, available for &lt;A href="https://blogs.sas.com/content/sasdummy/2012/12/06/copy-files-in-sas-eg/" target="_self"&gt;SAS Enterprise Guide 4.3 as a custom task.&lt;/A&gt; (In v7.13 and later, it's a built-in task that you can find on the Tasks-&amp;gt;Data menu.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Flow would look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="flow.png" style="width: 415px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17131i4DB9D06EFA080804/image-size/large?v=v2&amp;amp;px=999" role="button" title="flow.png" alt="flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Copy Files task might look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="copyfile.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17132i6AA93DC17A2AA27E/image-size/large?v=v2&amp;amp;px=999" role="button" title="copyfile.png" alt="copyfile.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example, the destination folder is the WORK directory.&amp;nbsp; The source file is explicitly named in the Copy Files "source" field, so this would change every time.&amp;nbsp; However, you could assign to a macro variable and use that reference here.&amp;nbsp; When the task runs, the source specification is stored in the &amp;amp;_EGCOPYSOURCE macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then your code to import can be more generic, like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.air;
    length
        date               8
        air                8 ;
        format date monyy5.;
    infile "%sysfunc(getoption(work))/*.csv"        
        lrecl=32767
        firstobs=2
        encoding="utf-8"
        dlm='2c'x
        missover
        dsd ;
    input
        date             : monyy5.
        air              : ?? best3. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The wildcard on the INFILE means that you don't need to name the specific file you just copied...as long as it's the only CSV in the destination folder (WORK, in this case).&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2017 13:19:42 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2017-12-11T13:19:42Z</dc:date>
    <item>
      <title>Getting the file name from importting wizard</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419901#M27013</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Every day I'm importing a .TXT file using the wizard.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I wonder if it is possible for SAS to capture the file name that I chose on the wizard, so that I can insert it in on a &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35692"&gt;@Char&lt;/a&gt; variable in a dataset.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Nowadays&amp;nbsp;I am including the file name manually in the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2017 10:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419901#M27013</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2017-12-10T10:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the file name from importting wizard</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419906#M27014</link>
      <description>&lt;P&gt;Plaese supply SAS platform and version you are using.&lt;/P&gt;
&lt;P&gt;Posting log of the running wizard maybe may help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know the fileref of importing you can achieve the file name.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2017 11:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419906#M27014</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-12-10T11:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the file name from importting wizard</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419919#M27015</link>
      <description>SAS Enterprise Guide 4.3</description>
      <pubDate>Sun, 10 Dec 2017 13:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419919#M27015</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2017-12-10T13:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the file name from importting wizard</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419956#M27016</link>
      <description>&lt;P&gt;If the file is the same each time, can you avoid the wizard? Usually a data step code is better anyways because you can make sure the file comes in the same each time. If you can do this, then there's a FILENAME and/or FILEVAR options that can help you get the file name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're using the wizard because its a local file being moved to the server, this won't work, unless you automate a step to upload the file to the server as well and then use the data step method.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2017 19:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/419956#M27016</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-10T19:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the file name from importting wizard</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/420097#M27019</link>
      <description>&lt;P&gt;I think that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has the best suggestion.&amp;nbsp; As far as I know, the Import Data task does not place the imported file name into any macro or environment variable, so there isn't a way to pull that detail from the wizard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, you could adjust your process to upload the text file to SAS, then run a SAS program node to complete the import.&amp;nbsp; The upload process would need to use the Copy Files task, available for &lt;A href="https://blogs.sas.com/content/sasdummy/2012/12/06/copy-files-in-sas-eg/" target="_self"&gt;SAS Enterprise Guide 4.3 as a custom task.&lt;/A&gt; (In v7.13 and later, it's a built-in task that you can find on the Tasks-&amp;gt;Data menu.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Flow would look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="flow.png" style="width: 415px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17131i4DB9D06EFA080804/image-size/large?v=v2&amp;amp;px=999" role="button" title="flow.png" alt="flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Copy Files task might look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="copyfile.png" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17132i6AA93DC17A2AA27E/image-size/large?v=v2&amp;amp;px=999" role="button" title="copyfile.png" alt="copyfile.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example, the destination folder is the WORK directory.&amp;nbsp; The source file is explicitly named in the Copy Files "source" field, so this would change every time.&amp;nbsp; However, you could assign to a macro variable and use that reference here.&amp;nbsp; When the task runs, the source specification is stored in the &amp;amp;_EGCOPYSOURCE macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then your code to import can be more generic, like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.air;
    length
        date               8
        air                8 ;
        format date monyy5.;
    infile "%sysfunc(getoption(work))/*.csv"        
        lrecl=32767
        firstobs=2
        encoding="utf-8"
        dlm='2c'x
        missover
        dsd ;
    input
        date             : monyy5.
        air              : ?? best3. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The wildcard on the INFILE means that you don't need to name the specific file you just copied...as long as it's the only CSV in the destination folder (WORK, in this case).&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 13:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-the-file-name-from-importting-wizard/m-p/420097#M27019</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-11T13:19:42Z</dc:date>
    </item>
  </channel>
</rss>

