Hi, Could someone give some help? I guess this piece of code is not correct to compare data I guess is that they are in different formats. The fisrt step generates a table with this results a.maxmargin_dt = 31JUL2019 and b.maxmodelmart_d= 355 And macro data generates ONEDT2 = 1190831 and month_id = 356 IF (maxmargin_dt >(&ONEDT2.)/100 ) and (maxmodelmart_d <> &month_id.) then export_flag='Y'; else export_flag='N'; This should result in export_flag = N because only the second conditions is true , however it results me as Y , so I guess despite of I had use (maxmargin_dt >(&ONEDT2.)/100 ) this converstion it is not working. Any help will be apprecciate I am not an expert in date and I have to use macro data functions because this is an automatic routine process. Kindly regards, %let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
data _null_;
date2=intnx("month",&today.,-1,'end');
call symput('ONEDT2',"1"||substr(put(date2,DDMMYYN.),7,2)||substr(put(date2,DDMMYYN.),3,2)||substr(put(date2,DDMMYYN.),1,2));
%put &ONEDT2.;
%put ONEDT2=&ONEDT2.;
month_id = intck('month','01jan1990'd,today());
put month_id=;
call symputx('month_id',month_id);
%put month_id=&month_id.;
run;
/*STEP 1 */
proc sql;
drop table IRM.TESTPAYG;
quit;
Proc SQL;
connect to teradata
(user=&teradata_user. password=&teradata_pwd. server = 'edwprod' database = 'nuc_pl_user_view');
Create table IRM.TESTPAYG as select * from connection to teradata(
select a.ID, a.maxmargin_dt, b.maxmodelmart_d from
(
select
1 as ID,
max(month_end_dt) as maxmargin_dt
from nuc_pl_user_view.pg_margin_stack) as A
left join (
select
1 as ID,
max(month_id) as maxmodelmart_d
from Insights_rm.Consumer_Model_Mart) as B
on a.ID = b.ID
);
disconnect from teradata ;
QUIT;
/* STEP 2 */
proc sql;
drop table IRM.TESTPAYG2;
quit;
DATA IRM.TESTPAYG2;
SET IRM.TESTPAYG;
IF (maxmargin_dt >(&ONEDT2.)/100 ) and (maxmodelmart_d <> &month_id.) then export_flag='Y';
else export_flag='N';
call symputx('export_flag', export_flag);
run;
... View more