☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Obsidian | Level 7

## Reproduce Stata GLM is SAS

I am trying to reproduce a GLM in SAS that I originally created in Stata. Although my estimates are exactly the same, the standard errors are not, and I'm not quite sure why. Note that cost is continuous while treatment, var1, and var2 are all categorical. Here is both codes:

SAS

```proc genmod data=data;
class clinician treatment var1 var2 / param=ref;
model cost = treatment var1 var2/ link=LOG dist=gamma type3;
repeated SUBJECT=clinician/ PRINTMLE TYPE=ind;
run;```

Stata

`glm cost i.treatment i.var1 i.var2, f(gam) l(log) cluster(clinician)testparm i.treatment`

Appreciate the help

1 ACCEPTED SOLUTION

Accepted Solutions
Obsidian | Level 7

## Re: Reproduce Stata GLM is SAS

Figured it out. The answer is twofold.

1) Genmod and Stata estimate the scale parameter and correlation structure slightly differently. Details are given on xtgee-related FAQ.

2) Genmod by default produces score type III tests while Stata produces Wald type III tests. Wald tests can be requested for SAS, but score tests cannot be produced by Stata.

8 REPLIES 8
Diamond | Level 26

## Re: Reproduce Stata GLM is SAS

Are the degrees of freedom the same? Show us.

--
Paige Miller
Obsidian | Level 7

## Re: Reproduce Stata GLM is SAS

Yes, DFs are all the same along with the estimates. Only the standard errors (and thus the p-values) are different)

Diamond | Level 26

## Re: Reproduce Stata GLM is SAS

How far apart are these estimates of standard errors? Give us a specific case, what are the actual numbers from SAS and what is the actual number in STATA?

What is the estimate of Scale from each program?

--
Paige Miller
Obsidian | Level 7

## Re: Reproduce Stata GLM is SAS

The estimate for treatment is -0.0356. In SAS, the standard error is 0.1301 while in Stata, the standard error is 0.1469.

I'm not sure how to find the scale in Stata, but the scale is SAS is 0.5432.

Diamond | Level 26

## Re: Reproduce Stata GLM is SAS

I don't understand, it seems as if you have not answered my question, or you did answer my question but worded it confusingly.

The standard error for treatment in SAS is _________________

The standard error for treatment in STATA is _________________

--
Paige Miller
Obsidian | Level 7

## Re: Reproduce Stata GLM is SAS

My apologies. My last reply had a few errors. It is rewritten, but to again answer your question:

The standard error for treatment in SAS is 0.1301.

The standard error for treatment in STATA is 0.1469.

Diamond | Level 26

## Re: Reproduce Stata GLM is SAS

Ok, so at this point, I have to say I don't really have enough familiarity with STATA to help further, but the problem (in my opinion) is either

1. the SAS algorithm estimates scale and standard errors differently than STATA algorithm does; or
2. the models specified are not identical (despite the matching estimates) because of the REPEATED command in PROC GENMOD produces different estimates of scale and different standard errors than STATA model specification does
--
Paige Miller
Obsidian | Level 7

## Re: Reproduce Stata GLM is SAS

Figured it out. The answer is twofold.

1) Genmod and Stata estimate the scale parameter and correlation structure slightly differently. Details are given on xtgee-related FAQ.

2) Genmod by default produces score type III tests while Stata produces Wald type III tests. Wald tests can be requested for SAS, but score tests cannot be produced by Stata.

Discussion stats
• 8 replies
• 453 views
• 1 like
• 2 in conversation