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;
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;
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."
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.