I am using the following code to create new variables but am having trouble creating the label/column header.
This is a monthly table - each month a new column is appended with that month's data. I am capturing the variable names and labels in macro variables and then using these to create new variables. The label name is a number, signifying the year and month ie this month's column is 200903. When I try to put the macro variable with this value as a column header, I get an error. Code as below.
proc contents data=reports.times_&yyyymm. out=work.contents noprint;
run;
data _null_;
set WORK.contents (where=(name ne "metric"));
call symput('var'||compress(_N_),compress(name));
call symput('label'||compress(_N_),compress(label));
call symput('n',compress(_N_));
run;
proc report data = reports.times_&yyyymm. NOWINDOWS NOCENTER MISSING
style(column)={font_size=10pt}
style(header)={font_size=10pt};
title;
title1 "Report 21";
footnote;
column metric _:;
%do i=1 %to &n;
column var&i;
define metric/display;
define &&var&i/display noprint;
define var&i/computed;
compute var&i/CHARACTER length=30 "&&label&i";
if index(metric,'LGD')>0
or index(metric,'PD')>0
or metric='Sum EL / Sum Pre-Severity EL' then var&i=put(&&var&i,&formb);
else var&i=put(&&var&i,&forma);
endcomp;
%end;
run;
Thanks in advance.