Hi everyone, I need some guidance as to how I should approach this data.I have count data that is collected over time in 3 month intervals. Everyone has a baseline session, but the final session varies. Some may have more follow up than others. I would like to show a decrease over time. Any feedback would be greatly apprecaited. Thanks!
The data is structed like this:
ID | Eventcount | SessionDate |
1 | 6 | 1/1/2015 |
1 | 4 | 1/31/2015 |
1 | 3 | 3/2/2015 |
1 | 2 | 4/1/2015 |
1 | 0 | 5/1/2015 |
2 | 3 | 2/1/2015 |
2 | 1 | 3/8/2015 |
2 | 0 | 4/12/2015 |
2 | 1 | 5/17/2015 |
2 | 0 | 6/21/2015 |
2 | 0 | 7/26/2015 |
3 | 12 | 3/3/2015 |
3 | 10 | 4/2/2015 |
3 | 9 | 5/2/2015 |
3 | 10 | 6/1/2015 |
3 | 11 | 7/1/2015 |
3 | 4 | 7/31/2015 |
3 | 2 | 8/30/2015 |
A very simplistic model could be:
proc reg data=have;
by id;
model eventcount= sessiondate;
run;
quit;
The parameter estimate for Sessiondate would be the average change per day over the period. The t value and Pr>|t| would indicate whether the change is significant. Though the number of records is kind of small.
Thanks Ballard, This was very helpful. Here is my output. Can you tell me why it says ChildID=2297? Right under the title? Also, can you confirm that I'm interperting this correctly - The change over time was 4.9 but it was not statistically significiant.
The example I provided assumed you wanted a report per ID as that seemed to make sense from the data. Your messages about insufficient variation indicates that some of your child id values have very little data. Also, dates as absolute values can sometimes lead to odd things in regression such as the intercept values. SOMETIMES instead of the date you might want to provide a "days since first measurement" to use.
If you want to have an overall behavior, ignoring the specific children then the days interval would be a better way to go.
data start;
informat ID Eventcount best4. sessiondate mmddyy10.;
input ID Eventcount SessionDate ;
datalines;
1 6 1/1/2015
1 4 1/31/2015
1 3 3/2/2015
1 2 4/1/2015
1 0 5/1/2015
2 3 2/1/2015
2 1 3/8/2015
2 0 4/12/2015
2 1 5/17/2015
2 0 6/21/2015
2 0 7/26/2015
3 12 3/3/2015
3 10 4/2/2015
3 9 5/2/2015
3 10 6/1/2015
3 11 7/1/2015
3 4 7/31/2015
3 2 8/30/2015
;
run;
proc sort data= start;
by id Sessiondate;
run;
data want;
set start;
by id;
retain FirstDate;
if first.id then FirstDate=SessionDate;
DaysInStudy = SessionDate-Firstdate;
drop firstdate;
run;
proc reg data=want;
model eventcount= DaysInStudy;
run;
quit;
The parameter estimate for DaysInStudy still refers to average change per day but now is scaled so that each person starts at day 0.
Hi Ballard,
Thanks for the explination. I took a slightly different approach. The program I am evaluating should have a baseline session then subsequent follow ups that occur in 3 month intervals. The majority of cases are resolved in a year. Some however span a longer time (2 years). What i'd like to see is if change occurs from the baseline session to the final session (completion of the program) and each session inbetween.
Here is what I did, I turned each date into the session variable:
proc sort data = start; by ID Date; run;
data start2;
set start;
by ID Date;
retain Session;
if first.ID then Session=1;
else if first.Date then Session+1;
run;
I then modeled the event count by the session:
proc reg data=Start2;
model EventCount = Session;
run;
quit;
Here are my results:
So are we saying from Baseline to the last session we found a 3.59 decrease that is statistically significant?
Thanks!
I would start with this:
data test;
input ID Eventcount SessionDate :mmddyy10.;
datalines;
1 6 1/1/2015
1 4 1/31/2015
1 3 3/2/2015
1 2 4/1/2015
1 0 5/1/2015
2 3 2/1/2015
2 1 3/8/2015
2 0 4/12/2015
2 1 5/17/2015
2 0 6/21/2015
2 0 7/26/2015
3 12 3/3/2015
3 10 4/2/2015
3 9 5/2/2015
3 10 6/1/2015
3 11 7/1/2015
3 4 7/31/2015
3 2 8/30/2015
;
proc sql;
create table test0 as
select
*,
intck("DAY", min(SessionDate), SessionDate) as SessionTime
from test
group by id;
quit;
proc glimmix data=test0;
class id;
model EventCount = SessionTime / dist=Poisson solution;
random intercept / subject=id;
estimate 'decrease' SessionTime 1 / lower ilink;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.