Freqsept parameters in %unistats

Updated: 01 Oct 2011

Introduction

The %unistats macro is not just for safety reporting. It is for efficacy reporting as well. It allows you to put whatever value(s) you want from ods tables created by "proc freq" or "proc glm" whereever you want (other procedures are due to be handled in the same way). It will run "proc freq" or "proc glm" internally for the variables you specify for the tests you want and will even transpose these tables to make the values more easy to use. You have complete flexibility over this. You can format the values however you like so that you can present the results in the way the client prefers. Examples for "proc freq" will be shown on this page.

What you need to know to use this feature are the "proc freq" tables option names and the ods tables that get created as a result. And you need to know the name of the variable(s) in these ods table that you require. To make it easier, if you start your ods table name with "Tr" it will transpose the table such that what is in "Name1" becomes the variable name and the value in "nvalue1" will be the value of that variable. You will see some examples of using the "Tr" prefix below.

If you know these table options and ods table names and what their values mean then you are probably a statistician. In which case you will be relieved to know that you no longer have to write code to call "proc freq" and to merge the values back in with the usual counts and percentages or to ask a SAS programmer to help you produce the table. It is done for you. This macro is as much a tool for the statistician as it is for the sas programmers in the trial reporting team.

Freqsept= parameters are part of the "tuplet" processing. You can add this feature to any existing safety reporting system. More details about "tuplet" processing can be linked to below.

Tuplet processing
 

Freqsept parameters

The "freqsept" parameters are so named because the values you supply get passed to "proc freq" and are in seven segments (septuplets) separated by "#". Here is the description of the parameters in the macro header:
 
 
/                   ------------------------------------------------------------
/ freqsept1-20      Proc freq septuplet statements for the placement of values 
/                   from ods tables in the output report/dataset in the form:
/                      varname(s)#keyword#missing#dset#statno#statord#code
/                   where "varname(s)" is the variable name or list of variable
/                   names separated by spaces,
/                  "keyword" is the proc freq option name,
/                  "missing" is "Y" or "N" for whether to include missing values
/                   in the calculation,
/                  "dset" is the ods table name with the attached where clause
/                   (if you prefix this table name with "Tr" it will transpose
/                   the table so that Name1 will become the variable name and
/                   Value1 its value),
/                  "statno"=1-9 for the STAT column number (you can also specify
/                   a treatment arm such as TRT1, TRT2 etc.),
/                  "statord" is the order number in the list of descriptive
/                   statistics and
/                  "code" is the code to format the value(s) for variables in
/                   the ods table.
/                   ------------------------------------------------------------

The seven segments of the freqsept parameters are as follows:

1) The variable name (a list of variables separated by spaces is allowed)
2) The keyword is the "proc freq" tables statement option
3) Missing is a "Y" or "N" to say whether missing values are to be included in the calculation
4) Dset is the ods table name produced as a result of using the keyword you specified. If you place "Tr" at the front of the name then it will make available a transposed version available.
5) Statno is the stats column in which to place the output for the variable you specify. You can use columns 1 - 9 for this. Alternatively you can give the treatment arm variable such as TRT1, TRT2 etc..
6) Statord in the order number of the statistic which will commonly be "1" (or "2" if you want to place another value underneath the first one)
7) Code is your put statement to format the results.
 

Example Code

Demo 1

The first demonstration uses the RISKDIFF option which will generate the RiskDiffCol1 table. We are interested in the "Difference" so we have to select on row="Difference" to obtain this value. It also uses the BINOMIAL option and here we use the table name "TrBinomialProp" so that the "Tr" start to the name will force a transpose of the "BinomialProp" table so that XL_BIN and XU_BIN become variable names instead of row values and so make it easier to reference more than one value.

Note that the column widths for the statistic columns STAT2, STAT3 and STAT4 have been set and labels supplied. The macro will calculate a p-value to show in the STAT1 column by default but as it is not desired in this case the variable is dropped using "filtercode=drop stat1".
 
/* Demonstrate %unistats freqsept parameters: demo 1 */ 

options noovp nodate nonumber center  ls=105
missing=" " formchar='|_---|+|---+=|-/\<>*';

title1; 

proc format; 
  value sexcd 
  1="MALE" 
  2="FEMALE" 
  ; 
  value trtnarr 
  1="Ambident@(1g/day)" 
  2="Betamax@(500mg/day)" 
  3="No@treatment" 
  ;
run; 
 

proc sort data=sasuser.demog(where=(fascd=1)) 
           out=demog(drop=fascd); 
  by patno invid; 
run; 

data demog; 
  set demog; 
  format trtcd trtnarr.;
  label sexcd="Gender" ; 
run; 

%popfmt(demog,trtcd,uniqueid=patno invid) 
 

%unistats(dsin=demog(where=(trtcd le 2)),total=yes,
stat2w=13,stat3w=13,stat4w=13,

stat2lbl="Difference of" "proportions" "[90% CI for" "difference]",
stat3lbl="95% CI for Response category MALE and Treatment Ambident",
stat4lbl="95% CI for Response category MALE and Treatment Betamax",

freqsept1=sexcd#alpha=.1 RISKDIFF#N#RiskDiffCol1(where=(row='Difference'))#2#1#compress(put(risk,percent8.1)),
freqsept2=sexcd#alpha=.1 RISKDIFF#N#RiskDiffCol1(where=(row='Difference'))#2#2#'['||compress(put(LowerCL*100,8.1))||';'||compress(put(UpperCL*100,8.1))||']',
freqsept3=sexcd#binomial#N#TrBinomialProp(where=(trtcd=1))#3#1#'['||compress(put(XL_BIN*100, 8.1))||'; '||compress(put(XU_BIN*100,8.1))||']',
freqsept4=sexcd#binomial#N#TrBinomialProp(where=(trtcd=2))#4#1#'['||compress(put(XL_BIN*100, 8.1))||'; '||compress(put(XU_BIN*100,8.1))||']',

trtlabel="Number of Patients (%)" " ", 
lowcasevarlist=sexcd,indent=2,
varlist=sexcd,
statvarlist=sexcd,
filtercode=drop stat1);

Here is the output produced by the program above.
 
_________________________________________________________________________________________________________

                                                                            95% CI for       95% CI for
                      Number of Patients (%)                                 Response         Response
                                                          Difference of      category         category
              Ambident        Betamax                      proportions       MALE and         MALE and
              (1g/day)      (500mg/day)       Total        [90% CI for       Treatment        Treatment
                (N=9)          (N=8)         (N=17)        difference]       Ambident          Betamax
_________________________________________________________________________________________________________

Gender
  Male         4 ( 44.4)      3 ( 37.5)      7 ( 41.2)        6.9%         [21.2; 86.3]     [24.5; 91.5]
  Female       5 ( 55.6)      5 ( 62.5)     10 ( 58.8)    [-32.2;46.1]

 

Demo 2

Note that in the above output, the second and third stats columns correspond to the two treatment arms. It would be better to place those values in those treatment arms as the last item. This is what will be done next.
 
/* Demonstrate %unistats freqsept parameters: demo 2 */ 

options noovp nodate nonumber center  ls=105 
missing=" " formchar='|_---|+|---+=|-/\<>*'; 

title1; 

proc format; 
  value sexcd 
  1="MALE" 
  2="FEMALE" 
  ; 
  value trtnarr 
  1="Ambident@(1g/day)" 
  2="Betamax@(500mg/day)" 
  3="No@treatment" 
  ;
run; 
 

proc sort data=sasuser.demog(where=(fascd=1)) 
           out=demog(drop=fascd); 
  by patno invid; 
run; 

data demog; 
  set demog; 
  format trtcd trtnarr.; 
  label sexcd="Gender" ; 
run; 

%popfmt(demog,trtcd,uniqueid=patno invid) 
 

%unistats(dsin=demog(where=(trtcd le 2)),total=yes, 
stat2w=13,stat3w=13,stat4w=13, 

stat2lbl="Difference of" "proportions" "[90% CI for" "difference]", 

freqsept1=sexcd#alpha=.1 RISKDIFF#N#RiskDiffCol1(where=(row='Difference'))#2#1#compress(put(risk,percent8.1)), 
freqsept2=sexcd#alpha=.1 
RISKDIFF#N#RiskDiffCol1(where=(row='Difference'))#2#2#'['||compress(put(LowerCL*100,8.1))||';'||compress(put(UpperCL*100,8.1))||']', 
freqsept3=sexcd#binomial#N#TrBinomialProp(where=(trtcd=1))#TRT1#9#'['||compress(put(XL_BIN*100, 8.1))||
'; '||compress(put(XU_BIN*100,8.1))||']', 
freqsept4=sexcd#binomial#N#TrBinomialProp(where=(trtcd=2))#TRT2#9#'['||compress(put(XL_BIN*100, 8.1))||
'; '||compress(put(XU_BIN*100,8.1))||']', 
trtlabel="Number of Patients (%)" " ", 
lowcasevarlist=sexcd,indent=2, 
varlist=sexcd, 
statvarlist=sexcd,
mincolw=13,
filtercode=
drop stat1;
if _statord=9 then _statlabel="95% CIs response category MALE");

You see that the two stats values are now in the treatment columns.
 
_________________________________________________________________________________________________________

                                                     Number of Patients (%)
                                                                                            Difference of
                                           Ambident          Betamax                         proportions
                                           (1g/day)        (500mg/day)         Total         [90% CI for
                                             (N=9)            (N=8)           (N=17)         difference]
_________________________________________________________________________________________________________

Gender
  Male                                     4 ( 44.4)        3 ( 37.5)        7 ( 41.2)          6.9%
  Female                                   5 ( 55.6)        5 ( 62.5)       10 ( 58.8)      [-32.2;46.1]
  95% CIs response category MALE         [21.2; 86.3]     [24.5; 91.5]

 

Conclusion

You have seen how you can use the "freqsept" parameters to place values from "proc freq" ods tables anywhere you choose in the output report.
 


 

Use the "Back" button of your browser to return to the previous page.

contact the author












SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.