<?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: Import MS Excel file with dynamic directory path follwing actual date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483316#M125327</link>
    <description>&lt;P&gt;2) -&amp;nbsp; I would advise you to present why XLS is not a good file format, for any purpose in this day an age.&amp;nbsp; It was discontinued 15 years ago in favour of the Open Office file format.&amp;nbsp; It is not portable - hence any other system than windows it will not work.&amp;nbsp; It has limited functionality.&amp;nbsp; From my experience other groups will not accept it.&amp;nbsp; No-one should be using such a difficult ancient file format as this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) - Yes, I can see that.&amp;nbsp; But a simple change to your process means that you would not have to - time saved, code writing saved, more robust etc.&amp;nbsp; Even if you only have xls there is nothing stopping someone from saving as csv from Excel, or batch job it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line" target="_blank"&gt;https://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Is one simple example of such a batch file to convert one file.&amp;nbsp; It is a simple matter to add that script and this one:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/16665748/vbscript-to-loop-through-all-files-in-a-folder" target="_blank"&gt;https://stackoverflow.com/questions/16665748/vbscript-to-loop-through-all-files-in-a-folder&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Together and voila, all the xls files are now csv.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Aug 2018 08:23:19 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-08-02T08:23:19Z</dc:date>
    <item>
      <title>Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483289#M125317</link>
      <description>&lt;P&gt;Hi every one,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a code in order to import different files which are named based on reported date. For example: "Loan 20180802.xls":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* I can import successfully with below code:

%let rpt_date = %sysfunc(today();yymmddn8.);

proc import out testing
        datafile= "d:\reports\loan &amp;amp;rpt_date.xls" dbms=xls replace;
        sheet="sheet1";
run;

* When I would like to have dynamic "rpt_date", I have tried below codes but failed:

%let rpt_date = today();
%let rpt_date_path = %sysfunc(rpt_date;yymmddn8.);

proc import out testing
        datafile= "d:\reports\loan &amp;amp;rpt_date_path.xlx" dbms=xls replace;
        sheet="sheet1";
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Would you mind instructing me solution?!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 06:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483289#M125317</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-02T06:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483296#M125318</link>
      <description>&lt;P&gt;The code you posted should not run at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; rpt_date &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;today&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;yymmddn8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;The colon after today() is wrong, a comma is required at this place.&lt;/P&gt;
&lt;P&gt;And in&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;datafile&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"d:\reports\loan &amp;amp;rpt_date.xls"&lt;/SPAN&gt; dbms&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;xls &lt;SPAN class="token keyword"&gt;replace&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;a second dot is required to get a normal named file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code should start with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option mprint mlogic symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so that you can see the code executed.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 06:59:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483296#M125318</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-08-02T06:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483305#M125320</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;has said, the code you present is invalid.&amp;nbsp; I would also ask why the process is trying to do everything the worst way possible.&amp;nbsp; For instance:&lt;/P&gt;
&lt;P&gt;You are using proc import - this is a guessing procedure, and will not import the data matching what you know the data should be except by fluke.&lt;/P&gt;
&lt;P&gt;You are putting "data" in the filename - date in this case - which makes coding harder, and you may miss that information.&lt;/P&gt;
&lt;P&gt;You are using an ancient version of Excel (as denoted by the xls), which is decades old and has been replaced by xlsx for at least 10 years or more.&amp;nbsp; XLS is proprietary binary format so not portable across systems, and only really usable on windows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest going back and looking thoroughly at the whole process, why do you get those files in, where do they come from, can they be got in a better way (access to a database, or using a good data transfer file format such as csv/xml).&amp;nbsp; Then have an import agreement which fixes down what the structure is of the data, and write a datastep import program which reads in the data exactly as you know it should be - in this way you know exactly how the output dataset will be.&amp;nbsp; For instance, it is simple to import a load of csv files in one datastep, get the date from the filename, and write out one dataset with a fixed structure:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "d:/reports/loan*.csv" filename=temp;
  date=strip(compress(compress(temp,"loan",""),".csv",""));
  ...
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Aug 2018 07:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483305#M125320</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-02T07:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483309#M125323</link>
      <description>&lt;P&gt;Thank Andreas_Ids for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was caused by my typo mistake. What I wanted was to have dynamic path with different dates. Not only "today".&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 07:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483309#M125323</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-02T07:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483312#M125324</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214133"&gt;@Tri_Luong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank Andreas_Ids for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It was caused by my typo mistake. What I wanted was to have dynamic path with different dates. Not only "today".&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Difficult to suggest something without knowing which dates should be inserted. There are multiple discussions in the communities explaining how to get filenames from a directory and import all/some files.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 08:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483312#M125324</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-08-02T08:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483313#M125325</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your kind advices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/ I am very new with SAS hence I have not&amp;nbsp;known other solutions to import data. The supports/advices by you are highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/ As in my company, they still use .xls file as source data, I use the options in my codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3/ My final purpose is writing a code so that I can import different files which are named based on different dates.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 08:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483313#M125325</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-02T08:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483314#M125326</link>
      <description>&lt;P&gt;Let say I would like to import 3 different files with similar names: Test 20180801.xls, Test 20180802.xls, Test 20180731.xls but I don't want to change the path. Instead, I would like to change a variables (%let) as my example codes mentioned initially.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 08:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483314#M125326</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-02T08:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Import MS Excel file with dynamic directory path follwing actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483316#M125327</link>
      <description>&lt;P&gt;2) -&amp;nbsp; I would advise you to present why XLS is not a good file format, for any purpose in this day an age.&amp;nbsp; It was discontinued 15 years ago in favour of the Open Office file format.&amp;nbsp; It is not portable - hence any other system than windows it will not work.&amp;nbsp; It has limited functionality.&amp;nbsp; From my experience other groups will not accept it.&amp;nbsp; No-one should be using such a difficult ancient file format as this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) - Yes, I can see that.&amp;nbsp; But a simple change to your process means that you would not have to - time saved, code writing saved, more robust etc.&amp;nbsp; Even if you only have xls there is nothing stopping someone from saving as csv from Excel, or batch job it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line" target="_blank"&gt;https://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Is one simple example of such a batch file to convert one file.&amp;nbsp; It is a simple matter to add that script and this one:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/16665748/vbscript-to-loop-through-all-files-in-a-folder" target="_blank"&gt;https://stackoverflow.com/questions/16665748/vbscript-to-loop-through-all-files-in-a-folder&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Together and voila, all the xls files are now csv.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 08:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-MS-Excel-file-with-dynamic-directory-path-follwing-actual/m-p/483316#M125327</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-02T08:23:19Z</dc:date>
    </item>
  </channel>
</rss>

