Next week, we will walk through a task that does power analysis for one-way anova. It will be an a large-scale modification of the built-in task for power analysis for pearson correlation. However, there are two elements of custom task development that you need to understand before we dive in that monster of a task. This week's post will help lay the ground work for next week. The first is a control called an Option Table, and the second is the Requirements portion of the VTL code. Both of which will be used several times in our task for allowing the user to provide as many values as they want.
The OptionTable element allows you to organize options into columns. You can choose add the addRemoveRowTools attribute, which will allow the user to add and remove rows from the table. This comes in handy for our use in the power task because for Significance Levels, Sample Sizes, and Power Values, proc power allows the user to specify as many numbers as they want.
Here's an example of an option table from the built-in Pearson Correlation task:
Here's the Metadata code for the Significance Level option table:
<Option inputType="string" name="alphaGroup">SIGNIFICANCE LEVEL</Option> <OptionTable addRemoveRowTools="true" initialNumberOfRows="1" label="Alpha values:" minimumRequiredRows="1" name="alphaTable" noIncompleteRows="true" showColumnHeadings="false"> <Columns> <Column defaultValues="0.05" label="Alpha" name="alpha"> <Option decimalPlaces="1,15" inputType="numbertext" invalidMessage="Enter a number for alpha that is greater than zero and less than 1" maxValue="0.99999999999" minValue="0.00000000001" missingMessage="Enter a number for alpha that is greater than zero and less than 1" promptMessage="Enter a number for alpha that is greater than zero and less than 1" rangeMessage="Enter a number for alpha that is greater than zero and less than 1" required="false"/> </Column> </Columns> </OptionTable>
Here's the SAS Code to access the values in the Significance Level option table:
## Alpha #set($_alpha=) #foreach($item in $alphaTable.rows.values) #if ($item.alpha) #set($_dummy=$_alpha.add("$item.alpha")) #end #end #if ($_alpha.size() > 0) alpha=#foreach($item in $_alpha) $item#end#end
The requirements element allows you to specify a list of conditions (or requirements) that must be met before the task can be run. If the condition is false, a message is printed in green in the SAS Code window, and no code is generated. Each requirement has two pieces, the condition and the message. Conditions can be quickly become complex if your requirement is based on several controls in your task.
One common use of the requirements element is to require that one value be less than another value. This is helpful in situations where the user needs to specify a maximum and minimum. You do not want the code to generated if the user specifies a maximum that is less than the minimum.
Here's an example of a requirement from the Pearson Correlation Task that does just that:
<Requirement condition="!( ($powerBySampleSizePlot == '1') && ($solveFor == 'solveforPowerChoice') && ($usePlotMinSSValue == '1') && ($usePlotMaxSSValue == '1') && ($MathTool.toDouble($ssMinValue) > $MathTool.toDouble($ssMaxValue)) )"> <Message nlsKey="minMaxSampleSizePlotRequirementKey">The maximum sample size for the power by sample size plot cannot be less than the minimum value.</Message> </Requirement>
This post doesn't have a task to download, but check out all other tasks from the Custom Task Tuesday series on our SAS Studio GitHub.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.