BookmarkSubscribeRSS Feed
manthan
Fluorite | Level 6

Hello All, 

 

I am currently working on a project on effects on antibiotics and hypoglycemia. I wrote the following code to generate a fisher plot for Hypoglycemia and antibiotics and other variables. The code given below worked completely fine and generated a table of odds ratios with confidence intervals and the corresponding Fisher Plot for the same. 

 

Now my question is I want to have another dependent variable besides HYPOGLYCEMIA. The other DEPENDENT variable is Severe Hypoglycemia and is also a 1/0 response like hypoglycemia. 

 

How do I modify the below code to get a fisher plot and odds ratios for both hypoglycemia and severe hypoglycemia on 1 plot? Is this doable? please help .. so basically the fisher plot would have two sets of odds ratios on it one for hypoglycemia and one for the other dv which is severe hypoglycemia.. 

 

Idk do I just do model hypoglycemia severe hypoglycemia = ... and leave everything else the same but I don't think that would work.. 

 

Below is the cod ethat worked for just hypoglycemia alone: 

ods output "Odds Ratios"=orci;
 
 
 
proc logistic data=data5 descending;
class Antibiotics (ref="0") GenderCode (ref="F") RenalDisease (ref="No") LiverFailure (ref="No")  Caucasian  (ref="0") AfricanAmerican (ref="0") Asian (Ref="0") OtherRace (Ref="0") Underweight (ref="0")  Normalweight(ref="0")  Obese (ref="0") 
 TPN (ref="No") TubeFeed (ref="No") Regulardiet (Ref="0") NPO (ref="No") sepsis (ref="No") UTI (ref="No") Cellulitis (ref="No") pneumonia (ref="No") ;
Model hypoglycemia= Antibiotics GenderCode RenalDisease LiverFailure Caucasian AfricanAmerican Asian OtherRace Underweight NormalWeight Obese TPN TubeFeed RegularDiet NPO Sepsis UTI Cellulitis Pneumonia;
where HistoryofDiabetes="No";
run;
 data orci;set orci;
effect=upcase(effect);
  run;
  
    title "SGPLOT: Forest Plot";
  proc sgplot data=orci;
scatter x=oddsratioest y=effect / xerrorlower=lowercl
 xerrorupper=uppercl
 markerattrs=or 
 (symbol=DiamondFilled size=8);
  
refline 1 / axis=x;
run;
3 REPLIES 3
ballardw
Super User

If you want to display two separate analysis then the basic steps are

1) run the Proc Logistic separately for each dependent variable creating a separate output data set for each.

2) combine the data sets with a data step Set and add a variable to indicate which data set contributed the data.

3) use that added variable in Proc Sgplot, using the new combined data, with a Group=variable option on the Scatter statement.

 

If you haven't combined data sets with such here is dummy code using the data set option IN= to provide values to create that suggested grouping var.

data combined;
   set set1 (in=in1)
       set2 (in=in2)
       <repeat as needed>
   end;
   length groupvar $ 25; /*make this large enough to hold the longest text you want*/
   if in1 then groupvar="meaning of set one";
   else if in2 then groupvar= "meaning of set two";
   /* repeat for additional sets and their IN variables*/
run;

and plot:

proc sgplot data=combined;
   scatter x=oddsratioest y=effect / group=groupvar xerrorlower=lowercl
   xerrorupper=uppercl
  ;

   refline 1 / axis=x;
run;

I removed MARKERATTRS as each group by default will have a different symbol for most ODS styles. If you want to change the default markers you would look at a  STYLEATTRS to change multiple.

This is one way. The other would be the create separate output sets from the logistic, combine them but rename the Y variable for each and use separate SCATTER statements for each with the different Y variable(s).

 

If you expect to do something about the interaction of the 2 dependent variables that is quite a different thing all together.

manthan
Fluorite | Level 6

thanks so much for your response 

 

so I have never done this before 

 

assuming data set 1 is the odds ratio for 1st dependent variable and called odds1

 

and data set 2 is the odds ratio for 2nd dependent variables and called odds2

 

can you tell me how the code you suggested would be written? pleaseeeee? sorry i am a little confused with what goes in stuff like in=, meaning of set1,2 etc

 

thanks so much

ballardw
Super User

@manthan wrote:

thanks so much for your response 

 

so I have never done this before 

 

assuming data set 1 is the odds ratio for 1st dependent variable and called odds1

 

and data set 2 is the odds ratio for 2nd dependent variables and called odds2

 

can you tell me how the code you suggested would be written? pleaseeeee? sorry i am a little confused with what goes in stuff like in=, meaning of set1,2 etc

 

thanks so much


Use Odds1 where I used Set1, use Odds2 where I used Set2 the data set creating combined.

Pretty much exactly as shown only use your data set names and meaningful values for the groupvar.

The <repeat as needed> would be if you created Odds3, Odds4 (until you get tired) and want to combine all of them for the same plot.

 

One thing to keep in mind for most combined plots is that one of the axis variables, the X axis for most, has to be the same name for each point plotted. The axis will adjust to handle different ranges of values (at least within reason) but the name is the same.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 463 views
  • 0 likes
  • 2 in conversation