<?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: How to automate the name of an excel file when importing it. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872428#M344691</link>
    <description>&lt;P&gt;You can use the system date instead of writing it manual. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out= cars
datafile= "C:/mydata/SampleData_%sysfunc(date(),yymmn6.).xlsx"
dbms= xlsx replace;
sheet="Sheet1";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2023 02:11:36 GMT</pubDate>
    <dc:creator>whymath</dc:creator>
    <dc:date>2023-04-27T02:11:36Z</dc:date>
    <item>
      <title>How to automate the name of an excel file when importing it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872425#M344688</link>
      <description>&lt;P&gt;Good Day, I'm trying to automate importing an excel file from a folder based on the most recent time period.&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import out= cars&lt;BR /&gt;datafile= "C:/mydata/SampleData_202304.xlsx"&lt;/P&gt;&lt;P&gt;dbms= xlsx replace;&lt;BR /&gt;sheet="Sheet1";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;It will import the file for April 2023 but for May 2023 I would have to manually change the file name. How can I automate that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 01:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872425#M344688</guid>
      <dc:creator>bradleyx</dc:creator>
      <dc:date>2023-04-27T01:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate the name of an excel file when importing it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872428#M344691</link>
      <description>&lt;P&gt;You can use the system date instead of writing it manual. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out= cars
datafile= "C:/mydata/SampleData_%sysfunc(date(),yymmn6.).xlsx"
dbms= xlsx replace;
sheet="Sheet1";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 02:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872428#M344691</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2023-04-27T02:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to automate the name of an excel file when importing it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872443#M344700</link>
      <description>&lt;P&gt;If you want the&amp;nbsp;&lt;EM&gt;latest&lt;/EM&gt; from a series of files:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
rc = filename(dref,"C:/mydata");
did = dopen(dref);
if did
then do;
  do i = 1 to dnum(did);
    name = dread(did,i);
    if substr(name,1,11) = "SampleData_" then output;
  end;
  rc = dclose(did);
end;
rc = filename(dref);
keep name;
run;

proc sort data=files;
by descending name;
run;

data _null_;
set files;
call symputx('name',name);
stop;
run;

proc import out= cars
datafile= "C:/mydata/&amp;amp;name."&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 06:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automate-the-name-of-an-excel-file-when-importing-it/m-p/872443#M344700</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-27T06:07:55Z</dc:date>
    </item>
  </channel>
</rss>

