BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

Hi folks, 

In this swimmer's plot, I'd like to show "dose levels" and "short texts" indicating histology of tumors inside the bars. Desirable image is shown below that I manually created in photoshop. 

SWIMMER PLOT DL AND TEXTS IN THE BAR.png

Dataset and initial proc sgplot is following. Can you please help add these details to the plot?

 

DATA SWIMMER1;
infile datalines dsd;
informat TRTCAP $12.;
INPUT SUBJID $ TRTSTDY TRTENDY ORDER TRTCAP $ DOSE_LEVEL $ TUMOR_HISTOLOGY $;
DATALINES;
24,1,28,1,,DL-2,TEXT1  
29,1,28,2,,DL-2,TEXT2  
20,1,28,3,,DL-2,TEXT3
21,1,29,4,,DL-2,TEXT3  
19,1,70,5,,DL-2,TEXT3  
22,1,91,6,,DL-2,TEXT3  
25,1,91,7,FilledArrow,DL-2,TEXT3
27,1,91,8,FilledArrow,DL-2,TEXT3
10,1,117,9,,DL-2,TEXT3
;
PROC PRINT; RUN; 
PROC SGPLOT DATA=SWIMMER1; 
HIGHLOW Y=ORDER LOW=TRTSTDY HIGH=TRTENDY / LOWLABEL=SUBJID TYPE=BAR 
HIGHCAP=TRTCAP; 
XAXIS LABEL='Study Day' VALUES=(0 TO 120 BY 30);
YAXIS LABEL='Subject ID' DISPLAY=(NOTICKS NOVALUES);
RUN; 

 Thank you for your time in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If you want to display text on many plots then a TEXT plot is the starting point.

PROC SGPLOT DATA=SWIMMER1; 
   HIGHLOW Y=ORDER LOW=TRTSTDY HIGH=TRTENDY / LOWLABEL=SUBJID TYPE=BAR 
      HIGHCAP=TRTCAP name='hl'; 
   text x=TRTENDY y=order text=TUMOR_HISTOLOGY 
            / position=left /*places text just left of coordinate*/
   ;
   XAXIS LABEL='Study Day' VALUES=(0 TO 120 BY 30);
   YAXIS LABEL='Subject ID' DISPLAY=(NOTICKS NOVALUES);
   keylegend 'hl';
RUN; 

You may want to provide a different horizontal coordinate variable if the values are too close to the end of the bar or you want to move them from the arrow portions.

View solution in original post

3 REPLIES 3
ballardw
Super User

If you want to display text on many plots then a TEXT plot is the starting point.

PROC SGPLOT DATA=SWIMMER1; 
   HIGHLOW Y=ORDER LOW=TRTSTDY HIGH=TRTENDY / LOWLABEL=SUBJID TYPE=BAR 
      HIGHCAP=TRTCAP name='hl'; 
   text x=TRTENDY y=order text=TUMOR_HISTOLOGY 
            / position=left /*places text just left of coordinate*/
   ;
   XAXIS LABEL='Study Day' VALUES=(0 TO 120 BY 30);
   YAXIS LABEL='Subject ID' DISPLAY=(NOTICKS NOVALUES);
   keylegend 'hl';
RUN; 

You may want to provide a different horizontal coordinate variable if the values are too close to the end of the bar or you want to move them from the arrow portions.

Cruise
Ammonite | Level 13
@ballardw thank you so much. Do you have any suggestions how to place Dose Levels in the beginning of each bar?
ballardw
Super User

@Cruise wrote:
@ballardw thank you so much. Do you have any suggestions how to place Dose Levels in the beginning of each bar?

You would provide an x coordinate for the LOW end of your highlow ploat and use the Position=Right so the text appears right of that coordinate:

PROC SGPLOT DATA=SWIMMER1; 
HIGHLOW Y=ORDER LOW=TRTSTDY HIGH=TRTENDY / LOWLABEL=SUBJID TYPE=BAR 
HIGHCAP=TRTCAP; 
text x=trtstdy y=order text=TUMOR_HISTOLOGY / position=right;
XAXIS LABEL='Study Day' VALUES=(0 TO 120 BY 30);
YAXIS LABEL='Subject ID' DISPLAY=(NOTICKS NOVALUES);
RUN; 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 937 views
  • 4 likes
  • 2 in conversation