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

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- SAS procedure/STATA procedure

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-10-2017 07:56 PM

Hello,

My question is about converting a STATA procedure to a SAS procedure.

Suppose I have continuous dependent variable y, 0<y<1, some independent variables, x1 - x10 (say). The STATA procedure to estimate y is:

glm y x1-x10/// family (binomial) link(logit).

If I understand correctly, the GLM procedure in SAS can not do logit. So, what is the SAS procedure that corresponds to glm in STATA?

The seond question is what is the best procedure in SAS that can handle the continuous proportion problem?

Thank you so much.

Rong

Accepted Solutions

Solution

07-11-2017
05:18 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-11-2017 11:20 AM

You say that your response, Y, has values between 0 and 1. That is, they are proportions. If your data are actually aggregated binary data and you have the numerator and denominator counts making up the proportions, then you can fit a logistic model in PROC LOGISTIC by using the events/trials syntax in the MODEL statement. For an example, see the Getting Started section of the LOGISTIC documentation. Specify the response in the MODEL statement as a ratio of event counts to total count. For example:

model Nevents/Ncounts = x1-x10;

However, if your response values are continuous proportions (such as proportions of area affected) that do not have numerator and denominator values, then models for such proportions are the so-called "fractional logit" and the 4- and 5- parameter logit models. The fractional logit model can be fit in PROC GLIMMIX and the 4- and 5- parameter logit models can be fit using PROC NLMIXED as discussed and illustrated in this note.

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-10-2017 08:49 PM

Hi:

I am not sure whether STATA code can directly be compared to SAS code. However, my students have recommended this web site, maintained by UCLA. They provide an overview of SAS here: http://stats.idre.ucla.edu/sas/modules/ and an overview of data analysis examples here: http://stats.idre.ucla.edu/other/dae/ that my students have recommended. The data analysis link contains a comparison of several different statistical languages: SAS, SPSS, R, and STATA. You might find it useful to read the example for doing analysis in the language you know and then reading about the same analysis when performed in a different software package.

cynthia

I am not sure whether STATA code can directly be compared to SAS code. However, my students have recommended this web site, maintained by UCLA. They provide an overview of SAS here: http://stats.idre.ucla.edu/sas/modules/ and an overview of data analysis examples here: http://stats.idre.ucla.edu/other/dae/ that my students have recommended. The data analysis link contains a comparison of several different statistical languages: SAS, SPSS, R, and STATA. You might find it useful to read the example for doing analysis in the language you know and then reading about the same analysis when performed in a different software package.

cynthia

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-11-2017 12:44 AM

Thank you, Cynthia.

Those are very good sites and I appreciate your help.

My question is very specific. What is the SAS counterpart of the STATA procedure "glm". Thanks again.

Rong

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-11-2017 08:40 AM

Make a dummy variable which has a value 1 . and feed it into proc logistic .

data have;

set have;

retain n 1;

run;

proc logistic data=have;

model y/n=x1-x10 /dist=bin ;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-11-2017 09:22 AM

I have never used STATA, but @Ksharp's method does not give the correct parameter estimates unless you also include a WEIGHT statement that contains the number of observations for each pre-summarized rate.

Solution

07-11-2017
05:18 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-11-2017 11:20 AM

You say that your response, Y, has values between 0 and 1. That is, they are proportions. If your data are actually aggregated binary data and you have the numerator and denominator counts making up the proportions, then you can fit a logistic model in PROC LOGISTIC by using the events/trials syntax in the MODEL statement. For an example, see the Getting Started section of the LOGISTIC documentation. Specify the response in the MODEL statement as a ratio of event counts to total count. For example:

model Nevents/Ncounts = x1-x10;

However, if your response values are continuous proportions (such as proportions of area affected) that do not have numerator and denominator values, then models for such proportions are the so-called "fractional logit" and the 4- and 5- parameter logit models. The fractional logit model can be fit in PROC GLIMMIX and the 4- and 5- parameter logit models can be fit using PROC NLMIXED as discussed and illustrated in this note.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-11-2017 05:22 PM

Thanks for all of you.

Ksharp, the option "dist=bin" produces an error, but SAS DOES accept "link=logit". Your thinking about "retain n 1;" is very suggestive. I haven't don't much reading about it, but you seem to suggest that any proportion problem can be modeled by the way you indicate. But then it makes me feel a little awkward to write statements like "model k/N = ..." in references.

Rick_SAS, your comment on "weight" is essential. Thank you.

StatDave_sas, I took your suggestion about "glimmix". Thank you.

I am sorry. I wanted accept everybody's comments as solution, but it seems that I am only allowed to choose one. When I picked one, I am completely blocked to choose others.