BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Squibbles
Fluorite | Level 6

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

4 REPLIES 4
Reeza
Super User

So what happens instead? What does the log say? Run the macro with MPRINT amd SYMBOLGEN on to see the exact code generated. 

Reeza
Super User

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

Squibbles
Fluorite | Level 6

ah good spot! i've been searching for the mistake all evening! Thank you

Squibbles
Fluorite | Level 6

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3300 views
  • 0 likes
  • 2 in conversation