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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.