<?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: Date macro variable not resolved in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525032#M142834</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your title says "Date macro variable not resolved". Where does that wording come from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the entire SASLOG related to this code you are running. Click on the {i} icon and paste it into the window that opens.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jan 2019 14:33:53 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-01-07T14:33:53Z</dc:date>
    <item>
      <title>Date macro variable not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525018#M142827</link>
      <description>&lt;P&gt;Dear All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer below code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Precode -
%let start_time=%sysfunc(datetime());
 
Postcode - 
 
 
%let end_time = %qsysfunc(datetime());

%let to_date=%sysfunc(today(),date9.);
%put &amp;amp;to_date.;
proc sql;
select max(datepart(start_time)) format =date9.
into :date from target.test_control where job_name='ch_1';
run;
%put &amp;amp;date.;
 


proc sql;
select max(datepart(start_time))
format = date9. into :up_time from target.test_control where job_name='ch_1';
run;
%put &amp;amp;up_time.;


%let today_dt=%sysfunc(datepart(%sysfunc(datetime())),date9.);
%put &amp;amp;today_dt.;
 
%macro execute;
%if &amp;amp;up_time.= &amp;amp;today_dt. 
%then %do;
proc sql;
update target.test_control
set start_time=&amp;amp;start_time.,
end_time=&amp;amp;end_time.,
last_update_time=&amp;amp;end_time.,
status ='Y'
&lt;STRONG&gt;where job_name='ch_1' and &amp;amp;date.=&amp;amp;to_date.;&lt;/STRONG&gt;
run;
%end;
%else %do;
proc sql;
insert into target.test_control values('flow_1',"&amp;amp;etls_jobname.",&amp;amp;start_time.,&amp;amp;end_time.,&amp;amp;end_time.,'sasdemo','Y');
run;
%end;
%mend;
%execute;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to update only new inserted(today's) observation in test_control table where max date of test_control table equal to today.&lt;BR /&gt;&lt;BR /&gt;Scenario :&lt;BR /&gt;&lt;BR /&gt;Trying to update few columns in test_control table based on two date macro variables which is created in above postcode section.&lt;BR /&gt;variable names and condition = &amp;amp;date.=&amp;amp;to_date. , While executing this code it return below error message.&lt;BR /&gt;&lt;BR /&gt;date macro variable contains maximum updated date in control table and to_date variable contains system date, so i just want to update the observation where these two dates has equal value(todays date value).&lt;BR /&gt;&lt;BR /&gt;Please refer "where" condition in macro.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Error Log -&lt;BR /&gt;&lt;BR /&gt;184 07JAN2019&lt;BR /&gt;_______&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;MPRINT(EXECUTE): update target.test_control set start_time=1862501204.91143, end_time=1862501204.93361,&lt;BR /&gt;last_update_time=1862501204.93361, status ='Y' where job_name='ch_1' and 07JAN2019=07JAN2019;&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, EQT, GE, GET,&lt;BR /&gt;GT, GTT, LE, LET, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 12:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525018#M142827</guid>
      <dc:creator>amol123</dc:creator>
      <dc:date>2019-01-07T12:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Date macro variable not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525032#M142834</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your title says "Date macro variable not resolved". Where does that wording come from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the entire SASLOG related to this code you are running. Click on the {i} icon and paste it into the window that opens.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525032#M142834</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-07T14:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Date macro variable not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525038#M142835</link>
      <description>&lt;P&gt;Omit the date9 formats, and use the raw date values in your macro variables. Otherwise you need to make complete SAS date literals like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;to_date."d&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525038#M142835</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-07T14:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Date macro variable not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525644#M143039</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class="login-bold"&gt;&amp;nbsp;kurtBremser,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank you for your inputs. Solution provided by you is working now. While creating date i have assigned date7. format for date which is working fine with your suggestion. Also i have made some changes in my current code(Changed the where condition) which gives me expected outputs. Please refer updated code.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;----------precode----------
%let start_time=%sysfunc(datetime());

----------postcode--------------
%let end_time = %qsysfunc(datetime());


%let to_date=&amp;amp;sysdate.;
%put &amp;amp;to_date.;


proc sql;
select max(datepart(start_time)) format =date7.
 into :date1 from target.job_control where job_name="&amp;amp;etls_jobname.";
run;
%put &amp;amp;date1.;






proc sql;
select max(datepart(start_time)) format =date7.
 into :up_time1 from target.job_control where job_name="&amp;amp;etls_jobname.";
run;
%put &amp;amp;up_time1.;






/*%put dt=%sysfunc(datepart(%sysfunc(datetime())));*/
/*%let today_dt1=%sysfunc(datepart(%sysfunc(datetime())));*/
%let today_dt1=&amp;amp;sysdate;
%put &amp;amp;today_dt1.;

data aa;
todate=put(today(),best.);
call symput ('today_dt',todate);
run;

%put &amp;amp;today_dt.;


%macro execute;
%if  "&amp;amp;up_time1"d = "&amp;amp;today_dt1"d 
%then %do;
proc sql;
update  target.job_control
set start_time=&amp;amp;start_time.,
 end_time=&amp;amp;end_time.,
 status ='Y'
/*where  "&amp;amp;date1"d="&amp;amp;to_date"d and  job_name='ch_1' and status='N';*/
where  datepart(start_time)=%sysfunc(today()) and  job_name="&amp;amp;etls_jobname.";
run;
%end;      

%else %do;

proc sql;
insert into target.job_control values('Dashboard1',"&amp;amp;etls_jobname.",&amp;amp;start_time.,&amp;amp;end_time.,'sasdemo','Y');
run;
%end;
%mend;
%execute;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Once again thank you for your valuable time.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 06:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-macro-variable-not-resolved/m-p/525644#M143039</guid>
      <dc:creator>amol123</dc:creator>
      <dc:date>2019-01-09T06:15:52Z</dc:date>
    </item>
  </channel>
</rss>

