Turn on suggestions

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

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Overlay plots from two different Proc Logistic

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 11-16-2021 01:37 PM
(1772 views)

Dear all,

I am running these two separate PROC LOGISTIC:

proc logistic data=covid plots=effect ( clband=yes SHOWOBS=NO );

model close2 (event='1') = policy close1 identif igrcont ;

proc logistic data=covid plots=effect ( clband=yes SHOWOBS=NO );

model distant2 (event='1') = policy distant1 identif igrcont ;

As you can see, the only difference is the criterion and one of the predictors in the model. The rest is identical. Below you can see the plots that I obtain for two models. I would like to know whether it is possible to combine them, in the same graph, ideally with different colors.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

9 REPLIES 9

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

I would output data sets (#2) with predicted probs and conf. limits.

Like here :

```
proc logistic data=sashelp.class plots=effect ( clband=yes SHOWOBS=NO );
model sex(event='F') = _NUMERIC_;
output out=work.toplot predicted=prd lower=lowcl upper=uppcl / ALPHA=0.10;
run;
```

Then concatenate both output datasets vertically (make an extra binary variable to indicate which data set the observations are coming from (with the indsname= option for example)), then use PROC SGPLOT with grouping functionality to draw both lines.

Can you do that or do you need help doing that?

Thanks,

Koen

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

hello Koen,

that's a good idea. I tried it, adding a category variable go use as a group in the new dataset containing the outputs of both proc logistic, but I am doing something wrong with SGPLOT. I used the SGPLOT syntax that I typically use with the output from the STORE function, so there's something I am missing. I attach my output.

```
proc logistic data=covid plots=effect ( clband=yes SHOWOBS=NO );
model distant2 (event='1') = policy distant1 identif igrcont ;
output out = mdistant predicted=prd lower=lowcl upper=uppcl / ALPHA=0.05;
run;
proc logistic data=covid plots=effect ( clband=yes SHOWOBS=NO );
model close2 (event='1') = policy close1 identif igrcont ;
output out = mclose predicted=prd lower=lowcl upper=uppcl / ALPHA=0.05;
run;
data mdistant; set mdistant (keep= prd lowcl uppcl ); gruppo='distant';
data mdistant; set mclose (keep= prd lowcl uppcl ); gruppo='close';
data tutti;
set mdistant mclose;
proc sgplot data=tutti noautolegend;
band x=policy upper=uppcl lower=lowcl / transparency=0.5 group=gruppo;
series x=policy y=prd;
yaxis label=" " min=0 max=1;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

Try sthg. like this :

Remark : I use NODUPKEY in PROC SORT because I have several IDs with same age.

This is just to make the plot "readable" and to prove to you this approach works.

```
proc logistic data=sashelp.class plots=effect ( clband=yes SHOWOBS=NO ) noprint;
model sex (event='F') = _NUMERIC_ ;
output out = mdistant predicted=prd lower=lowcl upper=uppcl / ALPHA=0.05;
run;
proc logistic data=sashelp.class plots=effect ( clband=yes SHOWOBS=NO ) noprint;
model sex (event='M') = _NUMERIC_ ;
output out = mclose predicted=prd lower=lowcl upper=uppcl / ALPHA=0.05;
run;
data tutti;
LENGTH gruppo $ 7;
set mdistant(in=int1)
mclose (in=int2);
if int1 then gruppo='distant';
else if int2 then gruppo='close';
else;
run;
proc sort data=tutti NODUPKEY; by gruppo age; run;
proc sgplot data=tutti noautolegend;
band x=age upper=uppcl lower=lowcl / transparency=0.5 group=gruppo;
scatter x=age y=prd / group=gruppo;
series x=age y=prd / group=gruppo;
yaxis label=" " min=0 max=1;
run;
```

Koen

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

that doesn't work well, but the syntax below works. I have to find a way not to print the single observations, and I am done!

```
data mdistant; set mdistant (keep= policy prd lowcl uppcl ); gruppo='distant';
data mclose; set mclose (keep= policy prd lowcl uppcl ); gruppo='close';
data tutti;
set mdistant mclose;
proc sort data=tutti; by gruppo;
proc sgplot data=tutti ;
reg x=policy y=prd / clm group=gruppo ;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I eventually found that in order to not having the datapoints on the graph it is enough to add the option NOMARKERS in the REG statement.

Thank you all for your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Sorry.

I misinterpreted your statement:

"I have to find a way not to print the single observations, and I am done!"

I thought you were done already when posting that, but you were still looking for the NOMARKERS option. 😕

Koen

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

thank you Koen. I meant to click on your response as the solution, but ended up clicking on my own reply!

Sorry about that.

Eman

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

No worries!

Keep contributing to (and profiting from) our communities I would say.

Have a nice Saturday evening and a nice Sunday,

Koen

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Ready to level-up your skills? Choose your own adventure.