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
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.
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
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;
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.