## Proc Genmod and continuous variables

Solved
Occasional Contributor
Posts: 7

# Proc Genmod and continuous variables

Hi All,

i'm not sure if this is possible, i've been searching for a while...

i need to get the coefficients, standard errors and Wald's confidence intervals for a continuous variable in Proc genmod.

I can get the co-efficient estimate for Age (BetaA), and i know i can multiply the coefficient by each age to get the coefficient for each age (i.e 33 * BetaA), however, i'm unsure on how to get the corresponding  Std. Error and Wald's confidence interval.

Also, it would be really handy if I can SAS to output the range of Ages used in ProcGenmod and output the values into ParameterEstimates (similar to the way it outputs them for categorical variables) - which is what  i really want!

Many thanks

``````PROC GENMOD DATA = GLMDataset ;
WEIGHT Quote. ;
CLASS 	Gender /MISSING ;
MODEL  PRICE = Gender Age
/DIST = Gamma.
TYPE1
TYPE3

;
OUTPUT 			OUT = GLMDatasetScored (keep = REFNO AVGPRICE PREMIUM: EST:. Gender Age )
PREDICTED	=	EST_AVGPRICE
LOWER		=	EST_LOWER_CI
UPPER 		=	EST_UPPER_CI
RESDEV 	=	EST_DEVRES
STDRESDEV	=	EST_STDDEVRES
RESLIK 		=	EST_LIKLRES

XBETA		=   EST_LINEARPREDICTOR
;
ods output 	parameterestimates =  _ParamEst
modelfit = _Modelfit
Type1 =  _Type1
Type3 = _Type3;
RUN;``````

Accepted Solutions
Solution
‎08-01-2017 05:58 AM
Super Contributor
Posts: 297

## Re: Proc Genmod and continuous variables

[ Edited ]

An other solution is to use proc plm for calculating predictions for any values in some dataset. In my little example I make a dataset "template" which contains the values of covariates. In your example this dataset should just have one observation with age=23.

The output data will contain the linear predictor. So if you want it on the original scale, you should add to this example a step where you calculate exp(pred). Confidence limit can be transformed with exp() also, and if you want the stderr on the original scale you should use the delta-rule.

``````*simulate som data;
data mydata;
do i=1 to 1000;
gender=(i<=500);
age=mod(i,100);
y=rand('gamma',exp(0.4*gender+0.01*age));
output;
end;
run;

*estimate the parameters and save the model;
proc genmod data=mydata;
class gender;
store mymodel;
run;

*constructing values of covariates for which we want predictions;
data template;
do gender=0,1;
do age=20 to 30;
output;
end;
end;
run;

*calculate confidence intervals with proc plm;
proc plm restore=mymodel;
score data=template out=predict lclm=lclm uclm=uclm stderr=stderr pred=pred;
run;``````

All Replies
SAS Employee
Posts: 281

## Re: Proc Genmod and continuous variables

If you want the predicted mean for any given age in a given gender, that is in your OUTPUT OUT= data set.  Just find the observation with the given age and gender.  If what you want is a predicted mean for age averaged over the genders, then this would be something the LSMEANS statement would do for you if age were a CLASS (categorical) variable in the model.  Since it's not, you can use the ESTIMATE statement to compute an estimate similar to an LS-mean.  For example, assuming there are two genders and you want to treat them as having equal proportions in the population, then this statement would estimate the mean for age=20:

estimate 'age=20' intercept 1 gender .5 .5 age 20;

Solution
‎08-01-2017 05:58 AM
Super Contributor
Posts: 297

## Re: Proc Genmod and continuous variables

[ Edited ]

An other solution is to use proc plm for calculating predictions for any values in some dataset. In my little example I make a dataset "template" which contains the values of covariates. In your example this dataset should just have one observation with age=23.

The output data will contain the linear predictor. So if you want it on the original scale, you should add to this example a step where you calculate exp(pred). Confidence limit can be transformed with exp() also, and if you want the stderr on the original scale you should use the delta-rule.

``````*simulate som data;
data mydata;
do i=1 to 1000;
gender=(i<=500);
age=mod(i,100);
y=rand('gamma',exp(0.4*gender+0.01*age));
output;
end;
run;

*estimate the parameters and save the model;
proc genmod data=mydata;
class gender;
store mymodel;
run;

*constructing values of covariates for which we want predictions;
data template;
do gender=0,1;
do age=20 to 30;
output;
end;
end;
run;

*calculate confidence intervals with proc plm;
proc plm restore=mymodel;
score data=template out=predict lclm=lclm uclm=uclm stderr=stderr pred=pred;
run;``````

Occasional Contributor
Posts: 7

## Re: Proc Genmod and continuous variables

great thanks, plm should get to what i want. i'll look into LSMeans and Estimate, that might help with communicating results to a non-technical audience.

Thank you both

SAS Employee
Posts: 281