BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rkong13
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

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

6 REPLIES 6
Cynthia_sas
SAS Super FREQ
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
rkong13
Calcite | Level 5

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

Ksharp
Super User

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;

Rick_SAS
SAS Super FREQ

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.

StatDave
SAS Super FREQ

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

rkong13
Calcite | Level 5

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.

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
  • 6 replies
  • 1795 views
  • 2 likes
  • 5 in conversation