Dear all,
I'm trying to run multiple models in a macro using macro variable as a predictor. However, instead of 14 models I get one model with 14 predictors plus covariates. Here is my code:
%let biomarker = TotalC nonHDLC RemnantC VLDLC ClinicalLDLC LDLC HDLC TotalTG VLDLTG LDLTG HDLTG TotalPL VLDLPL LDLPL;
%macro poisson ;
proc genmod data = met;
ods output ParameterEstimates=parm;
model comorbidity = &biomarker gestational_age birth_year child_sex/ alpha=0.0017 dist=poisson; run;
%mend poisson;
%poisson
Here is my output:
I would really appreciate an advice how to modify my code to obtain 14 models with each of the biomarkers as a separate predictor plus covariates.
You need a macro %DO loop.
%let biomarker = TotalC nonHDLC RemnantC VLDLC ClinicalLDLC LDLC HDLC TotalTG VLDLTG LDLTG HDLTG TotalPL VLDLPL LDLPL;
%macro poisson ;
%do i=1 %to %sysfunc(countw(&biomarker));
%let thisvar=%scan(&biomarker,&i,%str( ));
proc genmod data = met;
ods output ParameterEstimates=parm&i;
model comorbidity = &thisvar gestational_age birth_year child_sex/ alpha=0.0017 dist=poisson;
run;
%end;
%mend poisson;
%poisson
You need a macro %DO loop.
%let biomarker = TotalC nonHDLC RemnantC VLDLC ClinicalLDLC LDLC HDLC TotalTG VLDLTG LDLTG HDLTG TotalPL VLDLPL LDLPL;
%macro poisson ;
%do i=1 %to %sysfunc(countw(&biomarker));
%let thisvar=%scan(&biomarker,&i,%str( ));
proc genmod data = met;
ods output ParameterEstimates=parm&i;
model comorbidity = &thisvar gestational_age birth_year child_sex/ alpha=0.0017 dist=poisson;
run;
%end;
%mend poisson;
%poisson
Thank you so much, it worked!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: