Ah, that was a difficult problem that you encountered. In fact, the problem is caused by calls %trim()and %left().
Removing these results in code that works as intended (note, I also deleted the macro quoting the parameter):
%macro pass_parameter_with_equal_sign(table=, sqlOptions=);
proc sql
%if "&sqlOptions" ne "" %then %do;
&sqlOptions
%end;
;
create table macro_output as
select *
from &table;
quit;
%mend;
%pass_parameter_with_equal_sign(table=sashelp.class, sqlOptions= inobs=2);
We can recreate the problem you are facing:
%put %trim(inobs=1);
inobs = 1, %trim() , . , "inobs = 1", :
%let param = inobs=1;
%put %trim(%str(¶m));
. Amir %if , . , .
1 - %left() %trim
, "%left(%trim(&sqlOptions.))". , ( ), . , :
%let param = lots of spaces ;
%put ***¶m***;
:
***lots of spaces***
, , . , %str().
%let param = %str( lots of spaces );
%put ***¶m***;
:
*** lots of spaces ***
2 - ,
, , , %left() %trim(), , . :
%let param = %str( inobs = 2 );
, % str(), . , , :
%put %trim(¶m); * ALREADY QUOTED AT CREATION SO THIS WORKS FINE;
, %left(), :
%put %left(%trim(¶m)); * OOPS. DOESNT WORK;
, , , , , %trim() , . :
%put %unquote(%trim(¶m));
% str():
%put %left(%str(%trim(¶m)));
... % nrstr():
%let param = %str( inobs = 2 );
%put %left(%trim(%nrstr(¶m)));
... %sysfunc() datastep:
%put %sysfunc(compress(¶m));