- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello SAS users,
I have data for different treatments that I would want to show on a trend line. The treatments are all categorical data and collected over 4-time points.
I want to plot the prevalence of use of each of the 8 treatments on the same graph and then calculate their P for trend. If the treatments are (yes vs. No), how do I go about plotting the graphs? I figured that I can calculate the P-for trend via Cockrahe Armitage. Does anyone have an idea how I can plot all treatments on the graph and not separately? The Excel sheet is attached
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What you show is pretty clearly not a data set. So show what the DATASET looks like.
It may not hurt to mention trend of what. You show Yes/No as text combining a count and a percentage. So do you want to show a trend of Yes or No? Of the count or the percentage.
An example of what a data set to graph should look like and how to plot that with Treatment as a group variable.
data example; input treatment $ year percent; datalines; a 2000 .15 a 2001 .16 a 2002 .18 a 2003 .117 b 2000 .25 b 2001 .28 b 2002 .26 b 2003 .27 ; proc sgplot data=example; series x=year y=percent /group=treatment; yaxis values=(0 to .5 by .1); format percent percent5.; run;
/* or fit a line through the points but not connect*/ proc sgplot data=example;
reg x=year y=percent /group=treatment;
yaxis values=(0 to .5 by .1);
format percent percent5.;
run;
If you have a variable in the data set that has the Pvalue that is associated with the Treatment that can be added a couple of ways.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What you show is pretty clearly not a data set. So show what the DATASET looks like.
It may not hurt to mention trend of what. You show Yes/No as text combining a count and a percentage. So do you want to show a trend of Yes or No? Of the count or the percentage.
An example of what a data set to graph should look like and how to plot that with Treatment as a group variable.
data example; input treatment $ year percent; datalines; a 2000 .15 a 2001 .16 a 2002 .18 a 2003 .117 b 2000 .25 b 2001 .28 b 2002 .26 b 2003 .27 ; proc sgplot data=example; series x=year y=percent /group=treatment; yaxis values=(0 to .5 by .1); format percent percent5.; run;
/* or fit a line through the points but not connect*/ proc sgplot data=example;
reg x=year y=percent /group=treatment;
yaxis values=(0 to .5 by .1);
format percent percent5.;
run;
If you have a variable in the data set that has the Pvalue that is associated with the Treatment that can be added a couple of ways.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This is what i have from Excel
2000 | 2002 | 2004 | 2006 | |||||||||
Kind of treatment | Yes, n (%) | No, n (%) | P-value | Yes, n (%) | No, n (%) | P-value | Yes, n (%) | No, n (%) | P-value | Yes, n (%) | No, n (%) | P-value |
A | 633(6.5) | 9,177(93.5) | 591(6.2) | 8,599(93.8) | 691(6.2) | 10,428(93.8) | 710 (6.5) | 10,178 (93.5) | ||||
B | 848(8.7) | 8,951(91.3) | 745(8.1) | 8,411(91.9) | 901(8.1) | 10,184(91.9) | 886 (8.2) | 9,983 (91.8) | ||||
C | 150(1.5) | 9,674(98.5) | 124(1.4) | 9,045(98.6) | 177(1.6) | 10,945(98.4) | 172 (1.6) | 10,721 (98.4) | ||||
D | 111(1.1) | 9,700(98.9) | 112(1.2) | 9,045(98.8) | 143(1.3) | 10,964(98.7) | 183 (1.7) | 10,702 (98.3) | ||||
D | 523(5.3) | 9,295 (94.7) | 541(5.9) | 8,617(94.1) | 852(7.7) | 10,251(92.3) | 920 (8.5) | 9,967 (91.5) | ||||
E | 219(2.2) | 9555(97.8) | 237(2.6) | 8,870(97.4) | 363(3.3) | 10,681(96.7) | 327 (3.0) | 10,502 (97) | ||||
F | 152(1.6) | 9,642(98.4) | 129(1.4) | 9,009(98.6) | 173(1.6) | 10,898(98.4) | 195(1.8) | 10,652(98.2) | ||||
G | 438(4.5) | 9,380(95.5) | 422(4.6) | 8,748(95.4) | 563(5.1) | 10,552(94.9) | 571 (5.2) | 10,317 (94.8) | ||||
H | 2,987(30.5) | 6,821(69.5) | 2,808(30.7) | 6,352(69.3) | 3,593(32.4) | 7,508(67.6) | 3,700 (34) | 7,170 (66) |
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
We can't work from your Excel screen captures. You need to import the Excel file into SAS, and then show us it in SAS following these instructions, which will create SAS data step code that you can paste into your reply.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the response. The Gplot can't plot multiple graphs on the same paper. I am trying to plot a graph of prevalence (yeses/Yes + No) of treatments across 4 years and for them to be on the same graph. Tried proc GREPLAY and it worked. Thanks for the contribution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Create a SAS data set with variables TRT, YEAR, NYES, and N and one observation for each TRT-YEAR combination. The NYES variable should contain the number of Yes responses and the N variable should contain the overall number in each TRT-YEAR combination. With that data set, you can then fit the following model that allows for the linear YEAR effect to vary for the treatments. The EFFECTPLOT statement draws the graph. In the results, the test of YEAR in the Type 3 table tells you if there is an overall linear YEAR effect and the test of the interaction tells you if there are any differences in the YEAR effect across the treatments.
PROC LOGISTIC;
class trt / param=glm;
model nyes/n=trt|year;
effectplot slicefit(x=year sliceby=trt);
run;