Initial processing on macro invocation:
Declare local macro variable
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).
Assign parameter defaults:
Store line size:
Add total treatment group:
Repeat all the input observations for the total treatment
group (do whether requested or not)
Create a report for no data:
If there is no input data then call the macro defined
to nodata= to deal with it
Sort input data ready for a filter step (if performed):
(this will be done if anywhen=after is set)
Filter for anywhen=after:
(this is not done first time through)
Summarize for events:
(only done if events=Y)
Summarize for low level, mid level and high level
events
Get rid of duplicates from input data:
(now we have the event totals we want to drop duplicates
for subjects so we get the unique subjects)
Summarize for unique subjects:
Summarize for low level, mid level and high level
events
Merge in event counts if requested
Set up an "any low level term" which is really the
mid level subject count
Add in the "any low level term":
Include the "any low level term" with the rest of
the low level terms
Create a zero grid of subject count:
Create zeroes for all subject counts for all combinations
Merge on top of zero values:
Merge the real subject counts on top of the zero grid
Calculate percentages:
Calculate percentages based on the population total
dataset and set up _str which will have the subject count, percentage and
the event count (the latter if requested)
Set _str to spaces if the subject count is zero as
well as the population total zero
Calculate p-values:
If requested, call %npctpvals to calculate p-values
Transpose the datasets:
Transpose all the datasets using the treatment arm
as the ID value
Merge the separate transposed dataset back together
and add the pvalue dataset if created
minpct= and mincount= processing:
(If either of these is set then filter according to
the value specified. Filtering is done against the treatment arm value
defined to trtord= which be default is the total of all treatment arms).
minpctany= and mincountany= processing:
(If either of these is set then filter according to
the value specified. This applies to all treatment arms).
anywhen=after processing:
(If anywhen=Y then from the data we have left, create
a summary dataset with just those terms in so we can select the input data
with only those terms).
Branch to the filter step above ("Filter for anywhen=after")
Add default high level ordering variable if none specified (the
inverse of the count):
Add default mid level ordering variable if none specified (the inverse
of the count):
Add default low level ordering variable if none specified (the inverse
of the count):
Set default level ordering variables:
Calculate report width:
Limit the length of the high and mid level character variables:
(this is done because these values are shown across
the page of the report and are not allowed to flow. If they are too long
then "proc report" will refuse to show them).
Produce the report:
Delete temporary datasets:
Exit %npcttab: |