/* Program from Rick Wicklin, "Create a waterfall plot in SAS", The DO Loop, April 20, 2015. http://blogs.sas.com/content/iml/2015/04/20/waterfall-plot.html */ proc format; value RECISTFmt 1='Disease progression' 2='Stable disease' 3='Partial response' 4='Complete response'; run; data Tumor; format PatientID z4. Response percentN7. RECIST RECISTFmt.; input PatientID Response RECIST; datalines; 1001 -0.75 2 1002 -0.73 3 1003 -0.51 2 1004 -0.09 2 1005 -0.10 2 1006 -0.17 2 1007 -1.00 3 1008 -0.83 3 1009 -0.65 2 1010 -0.53 2 1011 -1.00 4 1012 -0.48 3 1013 -0.47 3 1014 -0.85 3 1015 -0.58 3 1016 0.54 1 1017 -1.00 3 1018 -0.68 3 1019 -0.25 1 1020 0.21 1 1021 -0.87 3 1022 -0.21 2 1023 -0.29 2 1024 -0.20 1 1025 -0.43 3 1026 -0.50 3 1027 -0.74 3 1028 -1.00 3 1029 -0.36 3 1030 -0.44 3 1031 0.22 2 1032 -0.59 3 1033 -0.26 2 1034 -0.89 3 1035 -0.57 3 1036 -0.72 2 1037 -0.76 3 1038 -0.66 3 1039 -0.44 3 1040 -0.31 3 1041 -0.40 3 1042 -0.57 3 1043 -0.74 3 1044 -0.13 2 1045 -0.07 1 1046 -0.05 2 1047 -0.29 2 1048 -0.51 3 1049 -0.70 3 1050 -0.35 3 1051 -0.43 3 1052 -0.34 2 1053 -0.87 3 1054 -0.34 3 1055 -0.59 3 1056 -0.45 3 1057 -0.26 2 1058 -0.22 2 1059 -1.00 3 1060 -0.75 3 1061 -0.83 2 1062 -0.38 3 1063 -0.70 3 1064 -0.12 2 1065 -0.32 3 1066 -0.15 2 1067 -0.49 3 1068 -0.50 3 1069 0.00 1 1070 -0.41 3 1071 -0.41 3 1072 -0.50 3 1073 -0.76 2 1074 -0.78 3 1075 -0.18 2 1076 0.00 1 1077 0.44 1 1078 -0.23 2 1079 -0.34 3 ; /* Sort by response and enumerate */ proc sort data=Tumor out=Waterfall; by descending Response RECIST; *use RECIST code to break ties; run; data Waterfall; set Waterfall; Position + 1; /* Position = _N_ */ run; title "Percent Change in Tumor Burden (N=79)"; footnote justify=left "After Gillespie (2012)"; footnote2 justify=left "Data from Kwak et al. (2010)"; /* Create a waterfall plot by using the VBAR (or HBAR) statement */ ods graphics / width=600px height=400px; proc sgplot data=Waterfall; refline -0.3 / axis=y lineattrs=(pattern=shortdash); vbar Position / response=Response group=RECIST; xaxis label="Patient Number" fitpolicy=thin; yaxis label="Change from baseline (%)" values=(-1 to 1 by 0.2) valueshint; keylegend / location=inside down=2; run; /* Alternative: use the NEEDLE statement */ ods graphics / width=579px height=400px; proc sgplot data=Waterfall; refline -0.3 / axis=y lineattrs=(pattern=shortdash); needle x=Position y=Response / baseline=0 group=RECIST lineattrs=(thickness=5px); xaxis label="Patient Number" values=(1, 5 to 75 by 5, 79) integer; yaxis label="Change from baseline (%)" values=(-1 to 1 by 0.2) valueshint; keylegend / location=inside down=2; run;