turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Logistic Regression in SAS

Topic Options

- 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

11-20-2014 03:02 AM

I have the data below

and here is my code to conduct logisic regression analysis. For some reason my code doesnt work. Any idea why?

data beetle_data;

input dose total dead;

y = dead/total;

datalines;

1.6907 59 6

1.7242 60 13

1.7552 62 18

1.7842 56 28

1.8113 63 52

1.8369 59 53

1.8610 62 61

1.8839 60 60

;

proc logistic data=beetle_data;

model

y =dose/link=logit dist=binomial;

run;

Accepted Solutions

Solution

11-20-2014
02:21 PM

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

Posted in reply to Günal

11-20-2014 02:21 PM

In my view, variable Y is not needed. I would start with:

**data beetle_data;**

** input dose total dead;**

** label dose="Log(dose)";**

** datalines;**

**1.6907 59 6**

**1.7242 60 13**

**1.7552 62 18**

**1.7842 56 28**

**1.8113 63 52**

**1.8369 59 53**

**1.8610 62 61**

**1.8839 60 60**

**;**

**proc logistic data=beetle_data plots(only)=effect;**

**model dead/total = dose;**

**run;**

PG

All Replies

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

Posted in reply to Günal

11-20-2014 06:34 AM

In proc logistic the default link is logit and dist is not in the option list. Try removing "/link=logit dist=binomial". Reference link: SAS/STAT(R) 9.2 User's Guide, Second Edition.

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

Posted in reply to Günal

11-20-2014 09:48 AM

Dependent variable Y is not a dichotomous dependent variable.

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

Posted in reply to Günal

11-20-2014 11:39 AM

Looks more like a PROC REG or similar procedure problem.

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

Posted in reply to Günal

11-20-2014 11:58 AM

I'd change the data structure to match what SAS was expecting, unless you're looking for an infection rate model, if so see here:

Otherwise something like the following might work:

data beetle_data;

input dose total dead;

y = dead/total;

datalines;

1.6907 59 6

1.7242 60 13

1.7552 62 18

1.7842 56 28

1.8113 63 52

1.8369 59 53

1.8610 62 61

1.8839 60 60

;

data have;

set beetle_data;

do record=1 to total;

if record <= dead then y_new=1;

else y_new=0;

output;

end;

run;

proc logistic data=have;

model y_new = dose / expb;

run;

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

Posted in reply to Reeza

11-20-2014 02:10 PM

Reeza, thanks for your work. Much appreciated. I am asking this because I am very new to SAS - is there no way to conduct the analysis in my way in SAS? Considering the fact that this could be done in R as shown below, I thought SAS too is able to do that.

`dose <- c(1.6907, 1.7242, 1.7552, 1.7842, `

1.8113, 1.8369, 1.8610,1.8839)

total<- c(59,60,62,56,63,59,62,60)

dead<- c(6,13,18,28,52,53,61,60)

y <- dead/total

lineer.model <- glm(y ~ dose,family=binomial(link=logit), weights=total)

which gives exactly the same coefficients as yours.

Solution

11-20-2014
02:21 PM

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

Posted in reply to Günal

11-20-2014 02:21 PM

In my view, variable Y is not needed. I would start with:

**data beetle_data;**

** input dose total dead;**

** label dose="Log(dose)";**

** datalines;**

**1.6907 59 6**

**1.7242 60 13**

**1.7552 62 18**

**1.7842 56 28**

**1.8113 63 52**

**1.8369 59 53**

**1.8610 62 61**

**1.8839 60 60**

**;**

**proc logistic data=beetle_data plots(only)=effect;**

**model dead/total = dose;**

**run;**

PG

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

Posted in reply to PGStats

11-20-2014 02:28 PM

PGStats thanks a million. That is exactly what I was after. I need one last favour. Do you mind sharing the code required for the lovely plot?

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

Posted in reply to Günal

11-20-2014 02:54 PM

It comes as part of the deal--the plots(only)=effect option to the PROC LOGISTIC statement.

Steve Denham

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

Posted in reply to SteveDenham

11-20-2014 03:11 PM

Steve, that is what I thought, but the plot does not appear in my output page. Could that have something to do with the version of SAS I am using (btw mine is Enterprise Guide 4.3)? Or does it appear somewhere else?

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

Posted in reply to Günal

11-20-2014 03:19 PM

Yeah, it is version dependent. Certainly available in 9.3 (SAS/STAT12.1) or later. Earlier versions require an ODS GRAPHICS ON; statement, but for SAS/STAT13.1 on, it is a default. And since my EG version is 6.1, I'm not sure how far back it goes.

Steve Denham

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

Posted in reply to Günal

11-21-2014 10:55 AM

EG 4.3 shipped with SAS 9.9m2, so make sure you have an explicity

ODS GRAPHICS ON;

statement before you call PROC LOGISITC.

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

Posted in reply to Günal

11-20-2014 03:44 PM

If it makes any sense in your context, you might also want to fit a natural mortality rate as part of your model. Proc Probit offers that feature:

**data beetle_data;**

**input logDose total dead;**

**dose = 10 ** logDose;**

**label logDose="Log(dose)";**

**datalines;**

**1.6907 59 6**

**1.7242 60 13**

**1.7552 62 18**

**1.7842 56 28**

**1.8113 63 52**

**1.8369 59 53**

**1.8610 62 61**

**1.8839 60 60**

**;**

**ods graphics on;**

**proc probit data=beetle_data log10 optc plots=predpplot;**

**model dead/total = dose / dist=logistic lackfit;**

**run;**

I find the fit slightly better this way.

PG

PG

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

Posted in reply to PGStats

11-21-2014 04:34 AM

PGStats, since I am using Enterprise Guide 4.3, ** plots=predpplot **does not produce the plot above. Is there some other way to do so?

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

Posted in reply to Günal

11-21-2014 10:48 AM

I'm sorry, I don't use EG. If the **plots=** option doesn't log an error it could be that the plot is generated somewhere but not shown to you... Just a guess.

PG