Hi, I have a Highlow plot for AEDECOD in term of study days for AE (AESTDY). I also want to add different treatment periods as a background using Block plot. After reading Sanjay's "The Block Plot" (https://blogs.sas.com/content/graphicallyspeaking/2014/04/14/the-block-plot/) I still did not know how to make it work. (1) I did not merge both datasets, instead I set them. (2) since EX did have periods without any treatment, I did not know how to reflect it. For example, dose 225ug starts day 1 and ends day 67. Next dose 75ug actually starts day 88. Ideally I would like day 68 to 87 to be blank in the graph. But current code did not do that.
Below is the code. Thanks a lot for help!
data ae; length USUBJID AEDECOD $200; USUBJID='subj1'; AEDECOD='Nasopharyngitis';aestdy=18;aeendy=26;output; AEDECOD='Sinusitis';aestdy=90;aeendy=105;output; AEDECOD='Headache';aestdy=176;aeendy=178;output; run; data ex; length USUBJID dose $200; USUBJID='subj1'; dose='225ug';exstdy=1;exendy=67;output; dose='75ug';exstdy=88;exendy=148;output; dose='225ug';exstdy=175;exendy=177;output; run;
proc sort data=ae;by USUBJID aestdy;run;
proc sort data=ex;by USUBJID exstdy;run;
data ae_ex; set ae ex; run; proc sgplot data=ae_ex; block x=exstdy block=dose/name='EX' transparency=0.5 /* valueHalign=center valueValign=top */ /* FillType=alternate AltFillAttrs=(transparency=1)*/ ; highlow y=AEDECOD high=aeendy low=aestdy/type=bar barwidth=0.8 fillattrs=(color=yellow); yaxis grid display=(noticks nolabel) valueattrs=(color=gray size=10pt) ; xaxis grid label="Study Days" labelattrs=(color=black size=10pt) valueattrs=(color=gray size=10pt) offsetmax=0.02 values=(-10 to 190) ; run;
Like this?
data EX;
length USUBJID DOSE $200;
USUBJID='subj1';
DOSE='225ug';EXSTDY= 1;EXENDY= 67;output;
DOSE='N/A ';EXSTDY= 67;EXENDY= 88;output;
DOSE='75ug ';EXSTDY= 88;EXENDY=148;output;
DOSE='N/A ';EXSTDY=148;EXENDY=175;output;
DOSE='225ug';EXSTDY=175;EXENDY=177;output;
run;
...
proc sgplot data=AE_EX;
block x=EXSTDY block=DOSE/name='EX' transparency=0.5 filltype=alternatelternate ;
highlow y=AEDECOD high=AEENDY low=AESTDY/type=bar barwidth=0.8 fillattrs=(color=yellow);
yaxis grid display=(noticks nolabel) valueattrs=(color=gray size=10pt) ;
xaxis grid label="Study Days"
labelattrs=(color=black size=10pt)
valueattrs=(color=gray size=10pt)
offsetmax=0.02 values=(0 to 190 by 10)
;
run;
Hi ChrisNZ,
Thanks a lot for help! Yes, I think this worked. In addition, I will add EXSTDY=0 and EXSTDY=178 with TRTA='N/A' so that both start and end are 'N/A'.
BTW, is there any way to assign colors for TRTA? For example, white for N/A, green for 25ug, blue for 75ug, red for 225ug? It puzzled me since BLOCK plot did not seem to have a group= option.
> is there any way to assign colors for TRTA?
You need to change the colours of GraphData1 - GraphDatan.
See here https://support.sas.com/rnd/datavisualization/gtl/concepts_sect5.htm
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.