Hello,
I'm trying to resolve the macrovariable &PROFILE that has a text: "ne devra représenter plus de 20 %du profil de gestion".
I get the Warning message: WARNING: Apparent invocation of macro DU not resolved.
Do you know please how to avoid this message?
Thank you very much!
Best regards,
Marie
Let's spell the issue out in more detail. You want to use macro variables to generate a string constant in a call to some object method in a data step. If you add double quotes around the value then the macro processor will try to evaluate the string value for possible macro references (% and/or & characters). If you build the string with single quotes instead then the macro processor will ignore the value of the string constant so % and/or & will be left alone.
You are attempting to add the quotes after generating the macro variable. You have no need for the unquoted string in your current program. So instead you could just add the quotes into the value of the macro variable when you create it. Note there is no need to create the &ith macro variable &i times by processing observations 1 to &i. Just use the one observation.
data _null_;
set RESULTAT (firstobs=&i obs=&i);
call symputx('PROFILE',quote(trim(PROFILE_NAME),"'"));
call symputx('PROFILE_OBJECTIVES',quote(trim(PROFILE_OBJECTIVES),"'"));
run;
Then just use the macro variable, no need to add any quotes since they are already in the macro variable value.
obj.format_cell(data: &profile
...
obj.format_cell(data: &PROFILE_OBJECTIVES
...
But best method is to just skip making the macro variables and use the actual dataset variables by reading in the observation you want in the data step that is making the object calls.
data _null_;
set RESULTAT (firstobs=&i obs=&i);
declare odsout obj();
...
obj.format_cell(data: PROFILE_NAME
...
obj.format_cell(data: PROFILE_OBJECTIVES
...
Use a proper macro quoting function
data _null_;
call symputx('profile', 'ne devra représenter plus de 20 %du profil de gestion');
run;
%put %superq(profile);
The first argument to %SYSFUNC must be a data step function.
Belay that, somehow the coffee must not have worked today.
try %superq()
data _null_;
call symputX('PROFILE', 'ne devra représenter plus de 20 %du profil de gestion', "G");
run;
%put %superq(PROFILE);
hmmm..
try with %qsysfunc()
data _null_;
call symputX('PROFILE', 'ne devra représenter plus de 20 %du profil de gestion', "G");
run;
%put %qsysfunc(quote(%superq(PROFILE)));
Not sure what this statement is. Why does the first line end in a comma and not a semi-colon? So assuming you want to run this statement:
obj.format_cell(data: %sysfunc(quote(%superq(PROFILE)))
,overrides: "font_face=Calibri just=left color=black font_size=10pt ")
;
Does that statement allow you to use single quotes instead of double quotes? Those will prevent the macro process from trying to evaluate the % and & triggers in the string.
obj.format_cell(data: %sysfunc(quote(%superq(PROFILE),%str(')))
,overrides: "font_face=Calibri just=left color=black font_size=10pt ")
;
Also does the syntax of that statement allow a variable or function instead of a string literal?
obj.format_cell(data: symget('PROFILE')
,overrides: "font_face=Calibri just=left color=black font_size=10pt ")
;
and how about this:
data _null_;
call symputX('PROFILE', 'ne devra représenter plus de 20 %du profil de gestion', "G");
run;
obj.row_start();
obj.format_cell(data:
"OBJECTIFS :" , overrides: "font_face=Calibri just=left font_weight=bold color=cx338AFF font_size=10pt width=2.6 cm");
obj.format_cell(data: %str(%')%superq(PROFILE)%str(%') ,
overrides: "font_face=Calibri just=left color=black font_size=10pt ");
obj.row_end();
for the format_cell
data portion(according to the doc) can be enclosed in single quotes.
Bart
or approach with `_temporary_variable_`?
data _null_;
call symputX('PROFILE', 'ne devra représenter plus de 20 %du profil de gestion', "G");
run;
filename out "%sysfunc(pathname(WORK))";
ods html close;
ods html path=Out file="test.html";
data _null_;
dcl odsout obj();
obj.table_start();
_temporary_variable_ = symget("PROFILE");
drop _temporary_variable_;
obj.row_start();
obj.format_cell(data: "OBJECTIFS :",
overrides: "font_face=Calibri just=left font_weight=bold color=cx338AFF font_size=10pt width=2.6 cm");
obj.format_cell(data: _temporary_variable_,
overrides: "font_face=Calibri just=left color=black font_size=10pt ");
obj.row_end();
obj.table_end();
run;
ods html close;
ods html;
Bart
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.