Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Reproduce Stata GLM is SAS

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-07-2022 09:26 AM
(452 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Are the degrees of freedom the same? Show us.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- the SAS algorithm estimates scale and standard errors differently than STATA algorithm does; or
- 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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.