BookmarkSubscribeRSS Feed
brophymj
Quartz | Level 8

 

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

 

 RowNamePrm1Prm2Prm3Prm4Prm5Prm6
Prm11-0.1487-0.0531-0.11-0.2161-0.1575
Prm2-0.148710.00790.01630.03210.0234
Prm3-0.05310.007910.00580.01150.0084
Prm4-0.110.01630.005810.02380.0173
Prm5-0.21610.03210.01150.023810.034
Prm6-0.15750.02340.00840.01730.0341

 

 

 

Paramter Estimates

 

RowNameEstimatesStd Error
Prm100
Prm2-0.00860.428094
Prm30.0771441.199069
Prm4-1.283690.578712
Prm50.2068580.294558
Prm60.4989410.404168

 

 

Standard Error of Differences

 

RowNamePrm1Prm2Prm3Prm4Prm5Prm6
Prm1      
Prm2      
Prm3
1481%
     
Prm4      
Prm5      
Prm6      

 

 

 

Standard Error of Differences
Factor 1Factor 2Std Diff (%)
Prm1Prm1
Prm1Prm2
Prm1Prm31481%
Prm1Prm4
Prm1Prm5
Prm2Prm2
Prm2Prm3
Prm2Prm4
Prm2Prm5
Prm3Prm3
Prm3Prm4
Prm3Prm5
Prm4Prm4
Prm4Prm5
Prm5Prm5

 

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.

 

1 REPLY 1
Ksharp
Super User
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});
     ..........your function of STD ...........
    output;
  end;
end;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1374 views
  • 0 likes
  • 2 in conversation