- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am trying to create a time series plot by EACH subject so the output will show graphs for each individual for 3 variables of interest with multiple dates. Each dates have several indexes that I would like to show that too.
Here is the sample dataset:
subjectID | aa | formGroup | i | visit_date | bb | cc |
1 | 16 | Day 1 | 1 | 1/19/2015 | 84 | 68 |
1 | 10 | Day 1 | 2 | 1/19/2015 | 92 | 82 |
1 | 10 | Day 1 | 3 | 1/19/2015 | 100 | 90 |
1 | 8 | Day 1 | 4 | 1/19/2015 | 104 | 96 |
1 | 10 | Day 2 | 1 | 1/20/2015 | 100 | 90 |
1 | 7 | Day 2 | 2 | 1/20/2015 | 100 | 93 |
2 | 10 | Day 1 | 2 | 4/12/2016 | 88 | 78 |
2 | 17 | Day 1 | 3 | 4/12/2016 | 81 | 64 |
2 | 15 | Day 1 | 4 | 4/12/2016 | 84 | 69 |
2 | 17 | Day 2 | 1 | 4/13/2016 | 93 | 76 |
2 | 14 | Day 2 | 2 | 4/13/2016 | 86 | 72 |
2 | 16 | Day 2 | 4 | 4/13/2016 | 74 | 58 |
Here is the code I have so far
PROC SGPLOT data = have;
BY subjectID;
scatter x = visit_date y = aa;
scatter x = visit_date y = bb;
scatter x = visit_date y = cc;
series x = visit_date y = aa;
series x = visit_date y = bb;
series x = visit_date y = cc;
RUN;
However, In addition to the Visit_date, I would like to include "I" variable so to show how values changed within that same day
Any help would be great!!
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can you show, somehow, an example of what you're trying to achieve?
@radhikaa4 wrote:
Hi
I am trying to create a time series plot by EACH subject so the output will show graphs for each individual for 3 variables of interest with multiple dates. Each dates have several indexes that I would like to show that too.
Here is the sample dataset:
subjectID aa formGroup i visit_date bb cc 1 16 Day 1 1 1/19/2015 84 68 1 10 Day 1 2 1/19/2015 92 82 1 10 Day 1 3 1/19/2015 100 90 1 8 Day 1 4 1/19/2015 104 96 1 10 Day 2 1 1/20/2015 100 90 1 7 Day 2 2 1/20/2015 100 93 2 10 Day 1 2 4/12/2016 88 78 2 17 Day 1 3 4/12/2016 81 64 2 15 Day 1 4 4/12/2016 84 69 2 17 Day 2 1 4/13/2016 93 76 2 14 Day 2 2 4/13/2016 86 72 2 16 Day 2 4 4/13/2016 74 58
Here is the code I have so far
PROC SGPLOT data = have;
BY subjectID;
scatter x = visit_date y = aa;
scatter x = visit_date y = bb;
scatter x = visit_date y = cc;
series x = visit_date y = aa;
series x = visit_date y = bb;
series x = visit_date y = cc;
RUN;
However, In addition to the Visit_date, I would like to include "I" variable so to show how values changed within that same day
Any help would be great!!
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What does i represent? should the distance between i=1 and i=2 be the same as between i=2 and i=4 within the same date? Or double distance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
i is the index. for example, each "Day" has multiple entries and I want to show all i's across each day for each patient
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just to get things started, here is what your data looks like and the SGPLOT Procedure
data have;
input subjectID $ aa formGroup $ i visit_date:mmddyy10. bb cc;
infile datalines dlm=',';
format visit_date mmddyy10.;
datalines;
1,16,Day 1,1,1/19/2015,84,68
1,10,Day 1,2,1/19/2015,92,82
1,10,Day 1,3,1/19/2015,100,90
1,8,Day 1,4,1/19/2015,104,96
1,10,Day 2,1,1/20/2015,100,90
1,7,Day 2,2,1/20/2015,100,93
2,10,Day 1,2,4/12/2016,88,78
2,17,Day 1,3,4/12/2016,81,64
2,15,Day 1,4,4/12/2016,84,69
2,17,Day 2,1,4/13/2016,93,76
2,14,Day 2,2,4/13/2016,86,72
2,16,Day 2,4,4/13/2016,74,58
;
proc sgplot data = have;
by subjectid;
series x = visit_date y = aa / markers;
series x = visit_date y = bb / markers;
series x = visit_date y = cc / markers;
run;
You can use the MARKERS Option in the Series Statement to create the markers instead of the Scatter Statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi! Thank you. I think we are almost there. The marker is ovelaying different Indexes (which 'i' variable) on top of each other for each. Is there any way to show across ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Which dot do you want connected when you have multiple on a single day, first/last, some statistic? Do you want the average instead?
@radhikaa4 wrote:
Hi! Thank you. I think we are almost there. The marker is ovelaying different Indexes (which 'i' variable) on top of each other for each. Is there any way to show across ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If Patient #1 has 3 Day 1 values, 2 Day 2 values so I want to connect day 1 index 1 to be connected to day 1 index 2 to be connected to day 1 index 3 to be connected to day 2 index 1 to be connected to day 2 index 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You want this ?
data have;
input subjectID $ aa formGroup $ i visit_date:mmddyy10. bb cc;
infile datalines dlm=',';
format visit_date mmddyy10.;
datalines;
1,16,Day 1,1,1/19/2015,84,68
1,10,Day 1,2,1/19/2015,92,82
1,10,Day 1,3,1/19/2015,100,90
1,8,Day 1,4,1/19/2015,104,96
1,10,Day 2,1,1/20/2015,100,90
1,7,Day 2,2,1/20/2015,100,93
2,10,Day 1,2,4/12/2016,88,78
2,17,Day 1,3,4/12/2016,81,64
2,15,Day 1,4,4/12/2016,84,69
2,17,Day 2,1,4/13/2016,93,76
2,14,Day 2,2,4/13/2016,86,72
2,16,Day 2,4,4/13/2016,74,58
;
proc sgpanel data=have;
panelby subjectID visit_date;
series x = i y = aa / markers;
series x = i y = bb / markers;
series x = i y = cc / markers;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This one ?
data have;
input subjectID $ aa formGroup $ i visit_date:mmddyy10. bb cc;
infile datalines dlm=',';
format visit_date mmddyy10.;
datalines;
1,16,Day 1,1,1/19/2015,84,68
1,10,Day 1,2,1/19/2015,92,82
1,10,Day 1,3,1/19/2015,100,90
1,8,Day 1,4,1/19/2015,104,96
1,10,Day 2,1,1/20/2015,100,90
1,7,Day 2,2,1/20/2015,100,93
2,10,Day 1,2,4/12/2016,88,78
2,17,Day 1,3,4/12/2016,81,64
2,15,Day 1,4,4/12/2016,84,69
2,17,Day 2,1,4/13/2016,93,76
2,14,Day 2,2,4/13/2016,86,72
2,16,Day 2,4,4/13/2016,74,58
;
proc sgpanel data=have;
by subjectID ;
panelby visit_date/onepanel layout=rowlattice novarname;
series x = i y = aa / markers;
series x = i y = bb / markers;
series x = i y = cc / markers;
run;