08-05-2015 12:35 PM
I am trying to perform conditional merging. Following is my code:
%let market_name = "AUS";
market = symget('market_name');
if market = "AUS" then
if market = "NZL" then
The above code is not merging the tables but is appending the variable even when the value is "AUS". The other work around that I could think about was dropping the added variable conditionally but that is also giving me error. Please help as to how should I solve this.
08-05-2015 01:50 PM
Lots of details about how the SAS data vector is built but since you want to conditionally create code then going a full macro route to allow macro conditional processing is an option:
%macro MyMarket (market=);
%if &market=AUS %then %do;
%if &market = NZL %then %do;
08-05-2015 01:54 PM
Set and Merge are not conditional statements. You need to use macro logic (%if/%then) inside a macro instead.
Or you could simplify your logic a bit, though this is a very bad example. The key idea is that BY and MERGE don't require the parameters which make flexible for dynamic programming.
%let merge_set = %sysfunc(ifc(&market_name=NZL, branch, %str()));
merge class &merge_set;