0
votes

I wrote a sas macro which require two input variable. Var1 is a date variable. var2 starts with and pern in( and ends with ), the bracket contains a serials of numbers which are separated by commas.

%let var1 = '01DEC2011'd;
%let var2 =  and pern in (10107,11308,11703,11850);

Now I first define the input variables, then define the macro and run it. It works fine

%let var1 = '01DEC2011'd;
%let var2 =  and pern in (10107,11308,11703,11850);

%macro program;
...
%mend;
%program;

However, I want to change the way I assign input variables, and let my macro looks like the following:

%macro program(var1, var2);
...
%mend;
%program( '01DEC2011'd, and pern in (10107,11308,11703,11850)); 

Because both var1 and var2 contains special characters ' , and (), so the macro cannot be exucuted correctly. Can anyone teach me how to call my macro please.

1
I don't see any issue with that macro definition or call. The () in the second value will protect the commas from being interpretted as indicating more parameter values. Did you actually try it? What error did you get?Tom

1 Answers

1
votes

I ran the following and it seems to work fine. What error are you getting?

%let var1 = '01DEC2011'd;
%let var2 =  and pern in (10107,11308,11703,11850);
%put &var1 '  ' &var2  ;

%macro test(var1,var2);
%put &var1 '  ' &var2;
%mend test;
%test('01DEC2011'd,and pern in (10107,11308,11703,11850));