BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ponnadahima
Calcite | Level 5

How can we get the below mentioned plot having doses (median and ranges) and timepoint on the same axis. Please suggest.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

Ksharp_0-1710220864030.png

 

View solution in original post

8 REPLIES 8
ballardw
Super User

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.

ponnadahima
Calcite | Level 5

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
;

 

Ksharp
Super User

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;

Ksharp_1-1710210217808.png

 

ponnadahima
Calcite | Level 5

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;

Ksharp
Super User
Then post a sample picture, so we know what kind of picture you want to look for.
Ksharp
Super User

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;

Ksharp_0-1710220864030.png

 

ponnadahima
Calcite | Level 5

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1532 views
  • 0 likes
  • 3 in conversation