<?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 Import file with variable directory in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485358#M126090</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I trying to import one excel file in folder: &lt;EM&gt;&lt;STRONG&gt;D:\/SAS Practice\Input data\data_testing09082018.xls&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; using dynamic path as below method:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_source = "D:\/SAS Practice\Input data\"
%let report_date = '09082018'd.;

proc import out=imported_data
         datafile= data_source report_date&lt;BR /&gt; &amp;nbsp;       dbms=xls replace;&lt;BR /&gt;         sheet="sheet1";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data new_data;&lt;BR /&gt;          set &lt;SPAN&gt;imported_data&lt;/SPAN&gt;;&lt;BR /&gt;          date_create = report_date;&lt;BR /&gt;          format date ddmmyyn8.&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My purpose is that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Variable "date_create" is formatted "dd/mm/yyyy" with the value as declared "&lt;SPAN&gt;report_date" above (09/08/2018).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Change the files to be imported when I change the value of "report_date".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3.I&amp;nbsp;am able to use "report_date" = today() if needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Thank everyone.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Aug 2018 07:29:45 GMT</pubDate>
    <dc:creator>Tri_Luong</dc:creator>
    <dc:date>2018-08-09T07:29:45Z</dc:date>
    <item>
      <title>Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485358#M126090</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I trying to import one excel file in folder: &lt;EM&gt;&lt;STRONG&gt;D:\/SAS Practice\Input data\data_testing09082018.xls&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; using dynamic path as below method:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_source = "D:\/SAS Practice\Input data\"
%let report_date = '09082018'd.;

proc import out=imported_data
         datafile= data_source report_date&lt;BR /&gt; &amp;nbsp;       dbms=xls replace;&lt;BR /&gt;         sheet="sheet1";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data new_data;&lt;BR /&gt;          set &lt;SPAN&gt;imported_data&lt;/SPAN&gt;;&lt;BR /&gt;          date_create = report_date;&lt;BR /&gt;          format date ddmmyyn8.&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My purpose is that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Variable "date_create" is formatted "dd/mm/yyyy" with the value as declared "&lt;SPAN&gt;report_date" above (09/08/2018).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Change the files to be imported when I change the value of "report_date".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3.I&amp;nbsp;am able to use "report_date" = today() if needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Thank everyone.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 07:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485358#M126090</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-09T07:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485359#M126091</link>
      <description>&lt;P&gt;See my comments:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_source = D:\SAS Practice\Input data\;
* missing semicolon here;
* don't use forward slashes;
* don't use quotes, as these would skewer your string later;

%let report_date = 09092018;
* same here: no quotes, please!;

proc import
  out=imported_data
  datafile="&amp;amp;data_source.data_testing&amp;amp;report_date..xls"
  /* reference macro variables with an ampersand, terminate macro variable references with a dot */
  /* file path needs to be a quoted string */
  dbms=xls
  replace
;
sheet="sheet1";
run;

data new_data;
set imported_data;
date_create = input("&amp;amp;report_date",ddmmyy8.);
/* since &amp;amp;report_date does not contain a SAS date literal (needs date9 format), use the input() function */
format date ddmmyyn8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&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;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I trying to import one excel file in folder: &lt;EM&gt;&lt;STRONG&gt;D:\/SAS Practice\Input data\data_testing09082018.xls&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; using dynamic path as below method:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data_source = "D:\/SAS Practice\Input data\"
%let report_date = '09082018'd.;

proc import out=imported_data
         datafile= data_source report_date&lt;BR /&gt; &amp;nbsp;       dbms=xls replace;&lt;BR /&gt;         sheet="sheet1";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data new_data;&lt;BR /&gt;          set &lt;SPAN&gt;imported_data&lt;/SPAN&gt;;&lt;BR /&gt;          date_create = report_date;&lt;BR /&gt;          format date ddmmyyn8.&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My purpose is that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Variable "date_create" is formatted "dd/mm/yyyy" with the value as declared "&lt;SPAN&gt;report_date" above (09/08/2018).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Change the files to be imported when I change the value of "report_date".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3.I&amp;nbsp;am able to use "report_date" = today() if needed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Thank everyone.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 07:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485359#M126091</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-09T07:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485361#M126093</link>
      <description>&lt;P&gt;Hi KurtBremser,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What a helpful and detailed answer! It worked. However, if I would like to change "rprt_date" = today(), how can I do with the same purpose?!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 07:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485361#M126093</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-09T07:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485362#M126094</link>
      <description>&lt;P&gt;To use data step functions in macro code, you need the %sysfunc() macro function; this also allows direct formatting of the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let report_date=%sysfunc(today(),ddmmyyn8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Aug 2018 08:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/485362#M126094</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-09T08:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486527#M126602</link>
      <description>&lt;P&gt;Dear &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_self"&gt;&lt;SPAN class="login-bold"&gt;KurtBremser&lt;FONT color="#b01600"&gt;,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;FONT color="#b01600"&gt;Could you please instruct me how to define "report_date" as previous working day since today (one working day before today, excluded holidays and weekends) ?! I know that I have to declare holidays somewhere but I don't know how to do it.&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 03:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486527#M126602</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-14T03:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486533#M126606</link>
      <description>&lt;P&gt;Use the weekday() function to determine Saturdays and Sundays, and the holiday() function for holidays depending on the date of "easter". Certain national holidays need to be determined by month and day.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 05:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486533#M126606</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-14T05:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486537#M126607</link>
      <description>&lt;P&gt;Thank Mr. KurtBremser,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I would like to utilise the code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let report_date=%sysfunc(today(),ddmmyyn8.);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to turn "report_date" is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;+ 1 previous working day (WHITHOUT holiday and weekend between)&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;+ 1 previous working day (WITH holiday and weekend between)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please instruct me the code for the 2 situations above!?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have tried below code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rprt_today = %SYSFUNC(TODAY(),yymmddn8.); 
%let rprt_yesterday = put(intnx('DAY',today(),-1),yymmddn8.);

data temp;
today = &amp;amp;rprt_today;
yesterday = &amp;amp;rprt_yesterday;
run;
　
PROC IMPORT OUT= LOAN_OVERDUE_YESTERDAY
DATAFILE="&amp;amp;RPRT_DIR_LOAN.OVD-LN-&amp;amp;rprt_yesterday. - COPY.XLS"
DBMS=XLS REPLACE;
SHEET="SHEET";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I got the notification:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"ERROR: Physical file does not exist, z:\reports\loan collections\daily loan overdue report\OVD-LN-put(intnx('DAY',today(),-1),yymmddn8.) - COPY.XLS."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From my observation, it might be because "rprt_today" turned out numeric value whilst "rprt_yesterday" turned out character value. Is it true?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 05:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486537#M126607</guid>
      <dc:creator>Tri_Luong</dc:creator>
      <dc:date>2018-08-14T05:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Import file with variable directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486548#M126614</link>
      <description>&lt;P&gt;Do your calculations for the previous workday in a data step, and use call symput() to store that value in a macro variable.&lt;/P&gt;
&lt;P&gt;Go back from today() in a loop, and check if the date is not a workday, according to local laws; as soon as you find a workday, leave the loop, and set the macro variable.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 06:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-file-with-variable-directory/m-p/486548#M126614</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-14T06:33:20Z</dc:date>
    </item>
  </channel>
</rss>

