Quartz | Level 8

## Estimating standard error of differences dynamically

Hi

I have a number of factors in my dataset and each factor has a number of levels. What I want to achieve is shown below. My code performs a proc genmod on the dataset for each factor which produces the first 2 tables below to a dataset. The first table shows the correlation matrix for one of the factors (which has 6 levels); the second dataset shows the parameter estimates and standard errors for each of the parameters.

I want the code to loop through each combination of paramters (there are 15 combinations) and calculate the standard error of the differences and output the results to a table like the last time shown below. The formula for the standard error of differences I am using is:

Std(p1-p2) = sqrt[ Std(p1)^2 + Std(p2)^2 - 2*Std(p1)*Std(p2)*corr(p1,p2) ]

Then this is divided by the difference in the two paramters

so Std(p1-p2)/(p1-p2)

I've tried using contrast and other statements but I need it to be this exact formula and to be able to create a macro that performs this for difference factors with difference number of levels.

 Correlation Matrix

 RowName Prm1 Prm2 Prm3 Prm4 Prm5 Prm6 Prm1 1 -0.1487 -0.0531 -0.11 -0.2161 -0.1575 Prm2 -0.1487 1 0.0079 0.0163 0.0321 0.0234 Prm3 -0.0531 0.0079 1 0.0058 0.0115 0.0084 Prm4 -0.11 0.0163 0.0058 1 0.0238 0.0173 Prm5 -0.2161 0.0321 0.0115 0.0238 1 0.034 Prm6 -0.1575 0.0234 0.0084 0.0173 0.034 1

 Paramter Estimates

 RowName Estimates Std Error Prm1 0 0 Prm2 -0.0086 0.428094 Prm3 0.077144 1.199069 Prm4 -1.28369 0.578712 Prm5 0.206858 0.294558 Prm6 0.498941 0.404168

 Standard Error of Differences

RowNamePrm1Prm2Prm3Prm4Prm5Prm6
Prm1
Prm2
Prm3
 1481%

Prm4
Prm5
Prm6

 Standard Error of Differences Factor 1 Factor 2 Std Diff (%) Prm1 Prm1 … Prm1 Prm2 … Prm1 Prm3 1481% Prm1 Prm4 … Prm1 Prm5 … Prm2 Prm2 … Prm2 Prm3 … Prm2 Prm4 … Prm2 Prm5 … Prm3 Prm3 … Prm3 Prm4 … Prm3 Prm5 … Prm4 Prm4 … Prm4 Prm5 … Prm5 Prm5 …

My proc genmod code that produces the correlation and paramter estimates table is shown below.

proc genmod data=insurancedata;

class glm31_cover_type(ref="COMP");

Weight NbClaims;

model AvgClaim = glm31_cover_type/ dist=gamma link=log obstats SCALE=DEVIANCE CORRB;

ods output ParameterEstimates =myObStats CORRB = CorrMatrix;

run;

I have attached my dataset.

Super User

## Re: Estimating standard error of differences dynamically

```Once you get Paramter Estimates and their Std Errors as you showed
You can use proc transpose firstly to get like:

Prm1	Prm2	Prm3	Prm4	Prm5	Prm6
0           0.428094    1.19 ..........

and use data step (double loop) to get what you want;

data want;
set have;
array x{*} prm1-prm6;
do i=1 to dim(x)-1;
do j=i+1 to dimx(x);
vname1=vname(x{i});
vname2=vname(x{j});