How can we get the below mentioned plot having doses (median and ranges) and timepoint on the same axis. Please suggest.
You want this ?
data example;
input idvar xvar l u;
datalines;
1 1 110 460
1 2 3022 4886
1 3 2399 6274
2 1 110 460
2 2 3256 4269
2 3 2313 5262
;
proc sgplot data=example noautolegend;
band x=xvar lower=l upper=u/group=idvar transparency=0.8; * fillattrs=graphdata1;
scatter x=xvar y=l/datalabel group=idvar datalabelpos=bottom datalabelattrs=( size=12 ) markerattrs=(size=0) labelstrip;
scatter x=xvar y=u/datalabel group=idvar datalabelpos=top datalabelattrs=( size=12 ) markerattrs=(size=0) labelstrip;
xaxis type=discrete;
yaxis display=none;
run;
Here is an example creating plot similar to your want:
data example; input idvar xvar yvar; datalines; 1 1 2 1 3 3 1 3 1 2 1 7 2 3 8 2 3 6 ; proc sgplot data=example; polygon x=xvar y=yvar id=idvar /fill; run;
You don't provide any data so have no clue as to what might be needed to convert your data to something that will plot similar to this.
Because of sort order likely issues I would suggest making sure that your x and y coordinates for the vertices of the triangles are numeric. If you need to display text like "Baseline" or "Week XX" I would suggest using a custom format to display text for the axis ticks for the values used.
Dear Ballardw,
Thanks very much for your quick reply. Please see my below data.
data example;
input idvar xvar l u;
datalines;
1 1 110 460
1 2 3022 4886
1 3 2399 6274
2 1 110 460
2 2 3256 4269
2 3 2313 5262
;
You'd better post your real data and exact graph you want to display, so I can test code.
data example;
input idvar xvar l u;
datalines;
1 1 11 11
1 2 10 12
1 3 9 13
2 1 4 4
2 2 3 5
2 3 2 6
;
proc sgplot data=example noautolegend;
band x=xvar lower=l upper=u/group=idvar fillattrs=graphdata1;
scatter x=xvar y=l/datalabel group=idvar datalabelpos=bottom datalabelattrs=(color=black size=12 ) markerattrs=(size=0) labelstrip;
scatter x=xvar y=u/datalabel group=idvar datalabelpos=top datalabelattrs=(color=black size=12 ) markerattrs=(size=0) labelstrip;
xaxis type=discrete;
yaxis display=none;
run;
Dear KSHARP,
Thanks very much for your response. This code worked a bit, but with my data it is not pointing like a triangle. See my sample data. I need this on urgent basis. I would be really thankful to you if this is resolved today. Thanks in advance!
data example;
input idvar xvar l u;
datalines;
1 1 110 460
1 2 3022 4886
1 3 2399 6274
2 1 110 460
2 2 3256 4269
2 3 2313 5262
;
run;
You want this ?
data example;
input idvar xvar l u;
datalines;
1 1 110 460
1 2 3022 4886
1 3 2399 6274
2 1 110 460
2 2 3256 4269
2 3 2313 5262
;
proc sgplot data=example noautolegend;
band x=xvar lower=l upper=u/group=idvar transparency=0.8; * fillattrs=graphdata1;
scatter x=xvar y=l/datalabel group=idvar datalabelpos=bottom datalabelattrs=( size=12 ) markerattrs=(size=0) labelstrip;
scatter x=xvar y=u/datalabel group=idvar datalabelpos=top datalabelattrs=( size=12 ) markerattrs=(size=0) labelstrip;
xaxis type=discrete;
yaxis display=none;
run;
Yes, as per my data, I got the same kind of plot. I used proc sgpanel which divided the treatments panel wise. hope this works with the customer as well! thanks a lot for your guidance in this regard.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.