Hi All,
hopefully, this will be an easy one!
i'm trying to write a macro for Proc Genmod and want to save the dataset for parameter estimates and model fit.
i've got it all working without a macro, however, when i "macrofy" it, i can't get the ODS output statement to generate the datasets. everything else works fine.
%Macro ProcGenmodMacro(LIBIN, DATAIN, varWeight, varClass, varModel, varDist, LIBOUT, DATAOUT, varKeep);
/*ODS GRAPHICS ON;*/
PROC GENMOD DATA = &LIBIN..&DATAIN. /*PLOTS= */ noprint;
WEIGHT &varWeight. ;
CLASS &varClass. ;
MODEL AVGPRICE = &varModel.
/DIST = &varDist.
LINK = LOG
TYPE1
TYPE3
/* CORRB
covb*/
;
OUTPUT OUT = &LIBOUT..&DATAOUT. (keep = &varKeep. &varModel.)
PREDICTED = EST_AVGPRICE
LOWER = EST_LOWER_CI
UPPER = EST_UPPER_CI
RESDEV = EST_DEVRES
STDRESDEV = EST_STDDEVRES
RESLIK = EST_LIKLRES
/*XBETA = EST_LINEARPREDICTOR
STDXBETA = EST_SEBETA*/
;
ods output parameterestimates = &LIBOUT..&DATAOUT.ParamEst
modelfit = &LIBOUT..&DATAOUT.Modelfit /*CorrB = CorrMatrix COVB = COVMATRIX*/;
RUN;
/*ODS GRAPHICS OFF;*/
%Mend;
Disregard previous post.
NOPRINT turns off the data generation for ODS, remove that option. If you'd like to not have output close the output destinations, see the post below on how that works.
http://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html
So what happens instead? What does the log say? Run the macro with MPRINT amd SYMBOLGEN on to see the exact code generated.
Disregard previous post.
NOPRINT turns off the data generation for ODS, remove that option. If you'd like to not have output close the output destinations, see the post below on how that works.
http://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html
ah good spot! i've been searching for the mistake all evening! Thank you
the proc genmod runs fine and it generates the output file fine. but it doesn't do the ODS line.
SYMBOLGEN and MPRINT shows the lines are generating fine:
MPRINT(PROCGENMODMACRO): ods output parameterestimates = GLM.Model1ParamEst modelfit =
GLM.Model1Modelfit ;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.