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

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.

 Screenshot 2021-11-16 at 19.36.05.png

 

Screenshot 2021-11-16 at 19.32.01.png

1 ACCEPTED SOLUTION
9 REPLIES 9
sbxkoenk
SAS Super FREQ

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

emaneman
Pyrite | Level 9

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;
sbxkoenk
SAS Super FREQ

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

emaneman
Pyrite | Level 9

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;
emaneman
Pyrite | Level 9

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.

sbxkoenk
SAS Super FREQ

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

emaneman
Pyrite | Level 9

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

sbxkoenk
SAS Super FREQ

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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 9 replies
  • 1878 views
  • 1 like
  • 2 in conversation