Mino Liu
Mino Liu

Reputation: 29

Set title using macro and proc report

I would like to create a macro to produce a report (proc report) for each datasets and include the title "Compulsion scale: Q6_#", but not sure how to add the title

%MACRO diff(var=);
%Let title = %var;
PROC REPORT DATA=table_&var.;
TITLE"CYBOCS COMPULSION SCALE: %var";
RUN;

%MEND diff;

OPTIONS MPRINT MLOGIC;
%diff(var=q6_1a);
%diff(var=q6_1b);
%diff(var=q6_2);
%diff(var=q6_3);
%diff(var=q6_4);
%diff(var=q6_5);
%diff(var=q6_6);
%diff(var=q6_7);
%diff(var=q6_date);

Upvotes: 0

Views: 560

Answers (1)

Tom
Tom

Reputation: 51566

The parameter to a macro is a local macro variable. To reference the value of a macro variable use & in front of its name.

%MACRO diff(var=);
PROC REPORT DATA=table_&var.;
TITLE "CYBOCS COMPULSION SCALE: &var";
RUN;
%MEND diff;

Upvotes: 1

Related Questions