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

Hello, 

 

I would like to create a plot with the probability of being treated on the y-axis and the contract-type (continuous variable between 0-1) on the x-axis. I would like to compare the effect of an increasing contract-type between the years, so I want to see this line graph per year and stacked in the same graph. 

 

This is what I have, but I am not sure how to show this with a different graph per year.

 

proc logistic data=data descending;

    model treated = contract y2011 y2012 y2013 y2011*contract y2012*contract y2013*contract;

store logit;

run;

 

title "Change in the probability of being treated by year and contract-type";

 

ODS GRAPHICS ON;

proc plm source=logit;

   effectplot slicefit(x=contract plotby=...);

run;

ODS GRAPHICS Off;

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

Instead of using several dummy variables in your model, use a single Year variable that has levels 2011, 2012, and 2013 (which you probably already have in your data). Then this will do it:

 

proc logistic;
class year;
model cb1=contract|year;
effectplot slicefit(x=contract sliceby=year)/noobs;
run;

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

It's not clear how your data are structured. Are y2011-y2013 dummy variables or something else?

 

Anyway, I think the correct way to structure the data for this analysis is to have the data in the "long form". You should create the variable YEAR with the values 2011, 2012, and 2013.

For ideas about how to convert from wide to long data, see "Reshaping data from wide to long."

 

Then you can model the data by using syntax such as 

CLASS YEAR;

MODEL treated = contract | year;

and you can use PLOTBY=YEAR in the effect plot. 

 

For examples of using the EFFECTPLOT statement, see "Use the EFFECTPLOT statement to visualize regression models in SAS."

StatDave
SAS Super FREQ

Instead of using several dummy variables in your model, use a single Year variable that has levels 2011, 2012, and 2013 (which you probably already have in your data). Then this will do it:

 

proc logistic;
class year;
model cb1=contract|year;
effectplot slicefit(x=contract sliceby=year)/noobs;
run;
GKati
Pyrite | Level 9
Thanks Stat_Dave! The issue with that is by doing that I’m forcing the annual change to be constant and I’m actually more interested in seeing the trend between years.

K.
StatDave
SAS Super FREQ

The code I showed fits a model equivalent to your original code. Mine just uses the CLASS statement to construct the dummy variables for Year internally rather than explicitly as in yours. Both treat Year as categorical which allows for any pattern of change in the response over time. And, because the interaction is in the model, they both allow the relationship between the response probability and Contract to change from year to year.

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!

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 2673 views
  • 3 likes
  • 3 in conversation