Hi all, Please help me have a look what is wrong with my code ? Thank you. Each week, I have 3 date, then I need to select the latest available file - ga.cust_yyyymmdd from that 3 dates. for example wk2 I have 3 date, 20190731, 20190730, and 20190729. I need to pick a date, if the file is available on 20190731, then I will use 20190731. if 20190731 do not have file, then I will pick 20190730 if 20190730 also do not have file, then I will pick 20190729. below is my code : %put compute to testing valid date : &wk2_a. &wk2_b. &wk2_c. &wk0_a &wk0_b &wk0_c; %macro date; %if %sysfunc(exist(ga.cust_&wk2_a.)) %then %do; %let wk2_dt=&wk2_a; %end; %else %if %sysfunc(exist(ga.cust_&wk2_b.)) %then %do; %let wk2_dt=&wk2_b; %end; %else %if %sysfunc(exist(ga.cust_&wk2_c.)) %then %do; %let wk2_dt=&wk2_c; %end; %if %sysfunc(exist(ga.cust_&wk0_a.)) %then %do; %let wk0_dt=&wk0_a; %end; %else %if %sysfunc(exist(ga.cust_&wk0_b.)) %then %do; %let wk0_dt=&wk0_b; %end; %else %if %sysfunc(exist(ga.cust_&wk0_c.)) %then %do; %let wk0_dt=&wk0_c; %end; %mend; %date; below is the log: %put compute to testing valid date : &wk2_a. &wk2_b. &wk2_c. &wk0_a &wk0_b &wk0_c; compute to testing valid date : 20190731 20190730 20190729 20190724 20190723 20190722 1993 1994 %macro date; 1995 1996 %if %sysfunc(exist(ga.cust_&wk2_a.)) %then %do; 1997 %let wk2_dt=&wk2_a; 1998 %end; 1999 %else %if %sysfunc(exist(ga.cust_&wk2_b.)) %then %do; 2000 %let wk2_dt=&wk2_b; 2001 %end; 2002 %else %if %sysfunc(exist(ga.cust_&wk2_c.)) %then %do; 2003 %let wk2_dt=&wk2_c; 2004 %end; 2005 2006 2007 %if %sysfunc(exist(ga.cust_&wk0_a.)) %then %do; 2008 %let wk0_dt=&wk0_a; 2009 %end; 2010 %else %if %sysfunc(exist(ga.cust_&wk0_b.)) %then %do; 2011 %let wk0_dt=&wk0_b; 2012 %end; 2013 %else %if %sysfunc(exist(ga.cust_&wk0_c.)) %then %do; 2014 %let wk0_dt=&wk0_c; 2015 %end; 2016 %mend; 2017 %date; 2018 2019 %put final file date= &wk0_dt. &wk2_dt.; WARNING: Apparent symbolic reference WK0_DT not resolved. WARNING: Apparent symbolic reference WK2_DT not resolved. final file date= &wk0_dt. &wk2_dt.
... View more