Hi experts,
I want to compare a hash value between some days and obtain a new table(s) with the results, just to known where the data has changed. The Second table has a day plus than the first table to make de evaluation and see if the next day has a different value. i'm not sure if i can do something like this :
%macro sqlloop(start,end);
PROC SQL;
DATE_FROM = '05MAY2019'D;
%DO ADD=&start. %TO &end.;
DATE_PLUS1=intnx('DAY',&DATE_FROM,1);
CREATE TABLE NewTable&ADD. as
SELECT t1.date, t1.account, t1.val_hash FROM table1 t1, table2 t2
WHERE t1.date = "&DATE_FROM"D AND t2.date = "&DATE_PLUS1"D
AND t1.account = t2.account
AND t1.VAL_HASH <> t2.VAL_HASH;
DATE_FROM=intnx('DAY',&DATE_FROM,1);
%END;
QUIT;
%mend;
%sqlloop(start=1, end=10)
table2 is a replicate of table1, just to make the comparisson between dates.
The val_hash column contains the data that i need to evaluate if it has changed.
I strongly suggest you make working code without using it in a macro - i.e. make a single iteration of your loop that works. Fill in constant values for a single iteration and debug it.
At the moment, if you removed all the macro-related parameters and variables, you would still have code that would generate error messages. For instance you have:
PROC SQL;
DATE_FROM = '05MAY2019'D;
/* ... other code here ... */
QUIT;
Run this and you'll see that it fails.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.