<?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: Apparent symbolic reference START_DATE not resolved. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937406#M368334</link>
    <description>&lt;P&gt;I've corrected your macro so it prints the start and end date values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro weekdays;
%global start_date end_date;
%let current_day = %sysfunc(today());
%let weekday = %sysfunc(weekday(&amp;amp;current_day.));

%if &amp;amp;weekday. = 2 %then %do;
    /* If it's Monday, fetch wednesday &amp;amp; Friday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
%end;
%else %if &amp;amp;weekday. = 3 %then %do;
 /* If it's Tuesday, fetch Thursday &amp;amp; Monday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;	
%else %if &amp;amp;weekday. = 4 %then %do;
 /* If it's Wednesday, fetch Friday &amp;amp; Monday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;	
%else %if &amp;amp;weekday. = 5 %then %do;
 /* If it's Thursday, fetch Monday &amp;amp; Wednesday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;
%else %if &amp;amp;weekday. = 5 %then %do;
 /* If it's Friday, fetch Tuesday &amp;amp; Thursday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;
%mend weekdays;

/*calculating last 3 weekdays based on logic*/
%weekdays;

%put &amp;amp;start_date.;
%put &amp;amp;end_date.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2024 03:40:43 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2024-07-29T03:40:43Z</dc:date>
    <item>
      <title>Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937395#M368326</link>
      <description>&lt;P&gt;I have an intial_data1 dataset that has my base data; I am trying to get last 3 weekday of data for every weekday between monday to friday for the whole month (the code runs on weekdays).&lt;BR /&gt;I have determined the logic and wrote a macro for calculating the previous 3 weekdays. I want to display the start and end date for my logic; I have called out the columns I want including the macro variable but I have the 'apparent symbolic reference' not resolved error.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro weekdays(start_date, end_date);
%let current_day = %sysfunc(today());
%let weekday = %sysfunc(weekday(&amp;amp;current_day.));

%if &amp;amp;weekday. = 2 %then %do;
    /* If it's Monday, fetch wednesday &amp;amp; Friday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
%end;
%else %if &amp;amp;weekday. = 3 %then %do;
 /* If it's Tuesday, fetch Thursday &amp;amp; Monday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;	
%else %if &amp;amp;weekday. = 4 %then %do;
 /* If it's Wednesday, fetch Friday &amp;amp; Monday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;	
%else %if &amp;amp;weekday. = 5 %then %do;
 /* If it's Thursday, fetch Monday &amp;amp; Wednesday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;
%else %if &amp;amp;weekday. = 5 %then %do;
 /* If it's Friday, fetch Tuesday &amp;amp; Thursday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;
%mend weekdays;


%put &amp;amp;start_date.;
%put &amp;amp;end_date.;



/*calculating last 3 weekdays based on logic*/
%weekdays(&amp;amp;start_date., &amp;amp;end_date.);

rsubmit;
proc delete data =myora.final_data;run;
proc sql;
connect to oracle(&amp;amp;ora_str.);
create table myora.final_data as
select * from connection to oracle(

select acct_num, mh_name, mh_cd, auth_dt, 
	  count(*) as total_auth_cnts, sum(auth_amt) as sum_auth_amt,
	  "&amp;amp;start_date."d as m_start_date,
      "&amp;amp;end_date."d as m_end_date
from initial_data1
where auth_dt &amp;gt;= TRUNC(SYSDATE) - 10  and auth_dt &amp;lt;= TRUNC(SYSDATE)
group by acct_num, mh_name, mh_cd, auth_dt
having 
	count(*) &amp;gt;= 10
	and sum(auth_amt) &amp;gt;= 100

);
disconnect from oracle;
quit;
endrsubmit;

%put m_start_date: &amp;amp;start_date.;
%put m_end_date: &amp;amp;end_date.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Error: 321  proc sql;
322  connect to oracle(&amp;amp;ora_str.);
323  create table myora.final_data as
324  select * from connection to oracle(
325
326  select acct_num, mh_name, mh_cd, auth_dt,
327        count(*) as total_auth_cnts, sum(auth_amt) as sum_auth_amt,
331        "&amp;amp;start_date."d as m_start_date,
WARNING: Apparent symbolic reference START_DATE not resolved.
332        "&amp;amp;end_date."d as m_end_date
WARNING: Apparent symbolic reference END_DATE not resolved.
333  from initial_data1
334  where auth_dt &amp;gt;= TRUNC(SYSDATE) - 10  and auth_dt &amp;lt;= TRUNC(SYSDATE)
335  group by acct_num, mh_name, mh_cd, auth_dt
336  having
337      count(*) &amp;gt;= 10
338      and sum(auth_amt) &amp;gt;= 100
339
340  );
ERROR: ORACLE prepare error: ORA-00923: FROM keyword not found where expected. SQL statement:
       select acct_num, mh_name, mh_cd, auth_dt, count(*) as total_auth_cnts,
       sum(auth_amt) as sum_auth_amt, , "&amp;amp;start_date."d as m_start_date, "&amp;amp;end_date."d as
       m_end_date from initial_data1 where auth_dt &amp;gt;= TRUNC(SYSDATE) - 10 and auth_dt &amp;lt;=
       TRUNC(SYSDATE) group by acct_num, mh_name, mh_cd, auth_dt having
       count(*) &amp;gt;= 10 and sum(auth_amt) &amp;gt;= 100.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
341  disconnect from oracle;
NOTE: Statement not executed due to NOEXEC option.
342  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.34 seconds
      cpu time            0.14 seconds

NOTE: Remote submit to ACXIOM complete.
556
557  %put m_start_date: &amp;amp;start_date.;
m_start_date: 25JUL2024
558  %put m_end_date: &amp;amp;end_date.;
m_end_date: 27JUL2024
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Jul 2024 22:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937395#M368326</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-07-28T22:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937396#M368327</link>
      <description>&lt;P&gt;You've defined your macro variables in your local SAS session but are trying to use them in your remote SAS session. You can use the %SYSLPUT statement to copy macro variables to your remote SAS session:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global start_date end_date;
%weekdays(&amp;amp;start_date., &amp;amp;end_date.);
%syslput _all_ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above copies all locally defined macro variables to the remote SAS session you last signed onto. You may also need a %GLOBAL statement to pick up macro variables defined inside a macro.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 22:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937396#M368327</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-07-28T22:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937398#M368329</link>
      <description>&lt;P&gt;But you never set any values into those macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you defined a macro that has START_DATE and END_DATE as parameters. So those are by definition LOCAL to the macro.&amp;nbsp; So they only exist while the macro is running.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then later you showed a call to the macro trying to pass in values from other macro variables that are also named START_DATE and END_DATE.&amp;nbsp; But you never showed any code that set those other macro variables.&amp;nbsp; It might be less confusing to use a different name for the macro variables you are using outside of the macro scope.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finally you have a third reference to macro variables START_DATE and END_DATE running on some remote SAS session.&amp;nbsp; You also do not show any place where the macro variables are given values in that SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does the remote SAS session have to do with the first part of your program?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 23:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937398#M368329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-28T23:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937404#M368332</link>
      <description>&lt;OL&gt;
&lt;LI&gt;I am trying to run a simulation for everyday from Monday to Friday and I also need to run another simulation for June month.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;in the proc sql table I want to select the acct_num, date, start date should be today-3 and end date should be start_date +2. I was trying to use the macro variables here.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;the logic included weekends , which I am trying to avoid by introducing macro variables.&lt;/LI&gt;
&lt;/OL&gt;
&lt;TABLE border="1" width="56.25%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="59px"&gt;auth_dt / day&lt;/TD&gt;
&lt;TD width="25%" height="59px"&gt;start date= auth_dt-3weekdays&lt;/TD&gt;
&lt;TD width="25%" height="59px"&gt;end date= start_date +2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;Monday&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Wednesday&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Friday&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;Tuesday&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Thursday&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Monday&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;Wednesday&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Friday&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Tuesday&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Thursday&lt;/TD&gt;
&lt;TD&gt;Monday&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Wednesday&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Friday&lt;/TD&gt;
&lt;TD&gt;Tuesday&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Thursday&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 29 Jul 2024 02:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937404#M368332</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-07-29T02:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937405#M368333</link>
      <description>Remote session - the remote session is to submit my code in a controlled environment with access to Oracle lib</description>
      <pubDate>Mon, 29 Jul 2024 02:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937405#M368333</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-07-29T02:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937406#M368334</link>
      <description>&lt;P&gt;I've corrected your macro so it prints the start and end date values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro weekdays;
%global start_date end_date;
%let current_day = %sysfunc(today());
%let weekday = %sysfunc(weekday(&amp;amp;current_day.));

%if &amp;amp;weekday. = 2 %then %do;
    /* If it's Monday, fetch wednesday &amp;amp; Friday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
%end;
%else %if &amp;amp;weekday. = 3 %then %do;
 /* If it's Tuesday, fetch Thursday &amp;amp; Monday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;	
%else %if &amp;amp;weekday. = 4 %then %do;
 /* If it's Wednesday, fetch Friday &amp;amp; Monday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;	
%else %if &amp;amp;weekday. = 5 %then %do;
 /* If it's Thursday, fetch Monday &amp;amp; Wednesday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;
%else %if &amp;amp;weekday. = 5 %then %do;
 /* If it's Friday, fetch Tuesday &amp;amp; Thursday */
    %let start_date = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);
	%let end_date   = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);
%end;
%mend weekdays;

/*calculating last 3 weekdays based on logic*/
%weekdays;

%put &amp;amp;start_date.;
%put &amp;amp;end_date.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 03:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937406#M368334</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-07-29T03:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937415#M368339</link>
      <description>&lt;P&gt;Take a BIG step back and review your code, and do it in a DATA step first:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
wd = weekday(today());
if wd = 2
then end_date = today() - 3;
else end_date = today() - 1;
if wd in (2,3,4)
then start_date = today() - 5;
else start_date = today() - 3;
call symputx("start_date",put(start_date,date9.),"g");
call symputx("end_date",put(end_date,date9.),"g");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you do not intend to call your code in the middle of a PROC or DATA step, there's no need to convert it to pure macro language, so you can avoid the %SYSFUNC avalanche.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS your macro as posted has a mistake, the "friday" calculation overrules the "thursday" calculation, as it is also triggered by weekday 5.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 07:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937415#M368339</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-07-29T07:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937450#M368359</link>
      <description>&lt;P&gt;I don't follow exactly what you are trying to do, but I think you are not breaking the task into the right sub parts to make it easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sounds like you want to do some calculation based on date multiple times (your simulation?).&amp;nbsp; So construct code that does that which takes the part the varies (I assume one or perhaps two date values) as input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro run_one(date);
%syslput date=&amp;amp;date ;
rsubmit;
... remote code that uses &amp;amp;date ...
endrsubmit;
%mend run_one;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then construct code that calls that once for each date you want to simulate.&amp;nbsp; Not clear to me what that is but perhaps you just want to loop over the days in June?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do date=mdy(6,1,2024) to mdy(6,30,2024);
     call execute(cats('%nrstr(%run_one)(',date,')'));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't want to run it for every day then change the loop.&amp;nbsp; Perhaps using INTNX() function and the WEEKDAY interval?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 13:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937450#M368359</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-29T13:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference START_DATE not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937528#M368376</link>
      <description>&lt;P&gt;Thank you, this worked. I used the data step rather than explicit macro.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 20:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-START-DATE-not-resolved/m-p/937528#M368376</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-07-29T20:21:40Z</dc:date>
    </item>
  </channel>
</rss>

