%unistats design specification

(Author: Roland Rashleigh-Berry                                                            Date: 03 Jun 2006)

Introduction

This document specifies the programming design for the %unistats macro. An overview of what the macro does is on the page you linked from. If you want to see the macro dependencies then click here.

Design specification

Initial processing on macro invocation:
   Declare local macro variables
   Declare global macro variables and set
   Store linesize

Check for enough parameters set:
   (Check all parameters for specification mistakes and report findings and abort at end of checking if an error is found).

Check stats labels map to keywords:
   (Make a call to %unimap to make sure any stats labels specified to the stats= parameter can be matched with a statistics keyword known to "proc univariate").

Pair stats keywords with their display format:
   (For each stats keyword, pair it with a format defined to the format parameters).

Prepare dataset and check that all variables are present:
   Create work dataset from dsin= specification
   Generate total for all treatment arms of requested
   Check that each variable requested is present in the resulting work dataset and exit after checks have completed if an exception was found.

Define macro %cat for processing categorical variables (an internal macro)

Define macro %num for processing numeric variables (an internal macro)

Create required formats:
   Create formats for p-value representation
   Create informat to map stats keyword to order position
   Create format that maps stats keywords to the stats labels used when the macro was called.

Start processing the data:
   Sort into &byvars &trtvar order
   Remove append dataset defined to dsout= if it exists

   For each variable, call %num or %cat macro:
      (depending whether the variable is character and (therefore call %cat) or numeric with a user format applied (therefore call %cat) or pure numeric (therefore call %num).

      %cat processing:
         Call %unipvals to calculate p-values if requested for that variable
         Sum the categories
         Merge on top of zero counts for categories if all format values requested
         Calculate percentages based on category total or population total depending on pctcalc= setting
         Append to the dsout= dataset
         Tidy up by deleting unwanted datasets

      %num processing:
         Call %unipvals to calculate p-values if requested for that variable
         Call "proc transpose" to calculate summary statistics
         Transpose to turn statistic keyword values into observations
         Append to the dsout= dataset
         Tidy up by deleting unwanted datasets

Add extra info to p-values dataset:
   Categorical variable p-values are given a _statord=1 value so they can be shown on the top line whereas numeric variable p-values are likely related to the MEAN value so assign _statord accordingly.

Sort output dataset into suitable order:
   Sort order will be defined in macro header. P-value dataset will be sorted in the same order.

Transpose output dataset by statistic name if requested:
   If dstranstat= set then transpose with _statname as the ID into output dataset

 Transpose output dataset by treatment arm if requested:
   If dstrantrt= set then transpose with &trtvar as the ID into output dataset
   Plug the gaps with zeroes but spaces where the treatment total is zero for a treatment arm

Call the %unicatrep macro if requested:
   Call the macro to print the dataset defined to dstrantrt= passing through parameters defined to %unistats when called

Exit the %unistats macro

Conclusion

This concludes the programming design specification for the %unistats macro.
 
Read more about: macro and dataset
Site Powered by FREE GoFTP Client