Programming the statistical procedures from SAS

SAS procedure/STATA procedure

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

SAS procedure/STATA procedure

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
SAS Employee
Posts: 281

Re: SAS procedure/STATA procedure

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

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,864

Re: SAS procedure/STATA procedure

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
Contributor
Posts: 21

Re: SAS procedure/STATA procedure

Posted in reply to Cynthia_sas

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

Super User
Posts: 10,020

Re: SAS procedure/STATA procedure

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;

SAS Super FREQ
Posts: 3,752

Re: SAS procedure/STATA procedure

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
SAS Employee
Posts: 281

Re: SAS procedure/STATA procedure

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

Contributor
Posts: 21

Re: SAS procedure/STATA procedure

Posted in reply to StatDave_sas

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 159 views
  • 2 likes
  • 5 in conversation