I'd like to develop a macro in which I can collect summary chi p value statistic for columns within my dataset (see code below). I'm trying to use %quote(&col) within a proc sql statement to insert the column name captured within a %do loop, but when I look at the resulting table, all I've captured is "&col". Does anyone have any advice?
Thanks.
proc sql;
select name into :chi_list separated by ' '
from model.metaclass
where format = '$' *identifies categorical variables;
%wordcount(&chi_list) *macro that generates the number of words in the list;
%macro chi_test;
%local col;
%do i = 1 %to &count;
let col = %scan(&chi_list,&i);
proc freq data = model.model_data;
tables &col / out = model.frq_&col2 chisq cellchi2;
by &resp; *referenced by outer macro process;
output out = model.chi_&col. chisq;
run;
proc sql;
insert into model.chisq_p;
select %quote(&col), P_PCHI from model.chi_&col.;
quit;