Reputation: 4152
I have the following simplified version of a piece of code that I am working on:
%macro test(var);
%if &var = 'Sub Prime' %then %do;
%let var2 = 'Sub_Prime';
%put &var2;
%end;
%mend;
%test(Sub%str( )Prime);
Basically the point of this is that if var = 'Sub Prime' that var2 should = 'Sub_Prime'. It appears though that var does not equal 'Sub Prime'. Can anyone tell me what I am doing wrong?
Thanks
Upvotes: 2
Views: 70
Reputation: 63434
Macro variables do not use quotations.
%macro test(var);
%if &var = %str(Sub Prime) %then %do;
%let var2 = Sub_Prime;
%put &=var2;
%end;
%mend;
%test(Sub%str( )Prime);
You'd be better off using %str
around the whole thing, though, rather than inserting the %str in just the space.
%test(%str(Sub Prime));
Upvotes: 3