This post is part of a mini-series leading up to PharmaSUG 2019 where I will be leading a hands-on training titled: Developing Custom SAS Studio Tasks for Clinical Graphs. For those who can't attend in person, I'll be posting about all of the tasks here on SAS Communities. Each task allows users to customize a different clinical graph from Sanjay Matange’s posts on Graphically Speaking.
This week on Custom Task Tuesday we will look at a task for creating and customizing this clinical waterfall graph (from this post of @Jay54's on the Graphically Speaking blog):
Like the post from last week and the post from the week before, this task includes options for changing the data source, variables, color scheme, legend position/location, and title. In addition to those options, this task also includes an option for a second title, as well as y-axis values (minimum, maximum, and increment).
Check out the task below:
I'll go through each portion of the task to show how to implement controls for customizing a Y-axis in a task for graph creation.
Here is the code from the Metadata section. It includes a group for the Y-axis controls, as well as 3 number text controls (for minimum value, maximum value, and increment value).
<Option inputType="string" name="GROUPYAXIS">Y AXIS VALUES</Option>
<Option defaultValue="-100" inputType="numbertext" invalidMessage="Invalid value. Enter a number between 0 and 100." maxValue="100" minValue="-100" missingMessage="Enter a number between 0 and 100." name="minYAXIS" promptMessage="Enter a number between 0 and 100." rangeMessage="This number is out of range. Enter a number between 0 and 100.">Minimum:</Option>
<Option defaultValue="60" inputType="numbertext" invalidMessage="Invalid value. Enter a number between 0 and 100." maxValue="100" minValue="-100" missingMessage="Enter a number between 0 and 100." name="maxYAXIS" promptMessage="Enter a number between 0 and 100." rangeMessage="This number is out of range. Enter a number between 0 and 100.">Maximum:</Option>
<Option defaultValue="20" inputType="numbertext" invalidMessage="Invalid value. Enter a number between 0 and 100." maxValue="100" minValue="-100" missingMessage="Enter a number between 0 and 100." name="incrementYAXIS" promptMessage="Enter a number between 0 and 100." rangeMessage="This number is out of range. Enter a number between 0 and 100.">Increment:</Option>
Below is the code for the UI section. The 3 numbertext controls go inside the YAXIS group.
<Group open="true" option="GROUPYAXIS">
<OptionItem option="minYAXIS"/>
<OptionItem option="maxYAXIS"/>
<OptionItem option="incrementYAXIS"/>
</Group>
Finally, here is the CodeTemplate section for the Y-axis values. This is the yaxis statement for PROC SGPLOT. We reference the $minYAXIS, $maxYAXIS, and $incrementYAXIS velocity macro variables from our controls.
yaxis values=($minYAXIS to $maxYAXIS by $incrementYAXIS);
Download the change in tumor size waterfall graph task on the Task Tuesday GitHub!
Use the hashtag #CustomTaskTuesday and tweet @OliviaJWright with your Custom Task comments and questions!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.