I cannot tell from the way you worded the question the exact value that is in the variable.
If you literally have this value in HOSPITAL
Children's Hospital
Then this statement:
call execute('%gn_transform(FILENAME='||FILENAME||', HOSPITAL='||HOSPITAL||');');
Is going to pass the following string to CALL EXECUTE
%gn_transform(FILENAME=somefilename,HOSPITAL=Children's Hospital);
and that is a problem because the string contains unbalanced quotes.
You could try adding macro quoting so that the value at least makes it into the macro call. (Also wrap the macro call in %nrstr() to delay calling the macro until the string is pull back off the stack to begin executing.)
call execute(cats('%nrstr(%gn_transform)(FILENAME=',FILENAME,', HOSPITAL=%nrstr(%bquote(',HOSPITAL,'));')));
Which should show line this on the SAS log
+ %gn_transform(FILENAME=somefilename,HOSPITAL=%bquote(Children's Hospital));
But that might cause trouble for the macro, depending on how it using the HOSPITAL macro variable.
So perhaps it would just be easier to modify the macro to expect the value of HOSPITAL to already include the quotes. Then the calling statement can just look like:
call execute(cats('%nrstr(%gn_transform)(FILENAME=',FILENAME,', HOSPITAL=',quote(trim(HOSPITAL)),');'));
And now the SAS log will show this instead:
+ %gn_transform(FILENAME=somefilename,HOSPITAL="Children's Hospital");
... View more