%unistats and %npcttab for MS Windows Users

(Author: Roland Rashleigh-Berry                                                    Date: 27 Sep 2011)

Introduction

Spectre was originally written for Unix but got ported over to Windows in February 2007. However, its main reporting macros %unistats and %npcttab were never platform specific. They can be used on any platform that SAS runs on. You can run both %unistats and %npcttab independently of Spectre so you need not be deprived of these two very powerful and flexible macros. The example code and output shown on this web site for those two macros all ran using SAS Learning Edition 4.1 on my PC independently of Spectre so they will certainly work for you under Windows. You can link to these pages below and run this code yourself.
%npcttab
%unistats
 

%npcttab and %unistats as "standard macros"

If you use these macros, then you might think they are limited to the layout of the reports they give and the p-values they can calculate but that is not the case. The macros were designed to be very flexible and are intended for use by any and all pharmaceutical companies and CROs. Neither of these macros are tied to a report layout style. %unistats does not produce a report by default and the report capability of %npcttab can be disabled using print=no and they will give you output datasets that you are free to present in any style you wish. If you require p-values these macros can not currently give then you can calculate them yourself in your code and merge these p-values in with the output datasets and then produce a report in any required layout style. Bearing in mind that these two macros will run on any platform and are free to anybody to download and use, then perhaps they are the first macros ever released with a claim to being called "standard macros" for safety reporting across the pharmaceutical industry. As you get to know the output datasets from these macros you can think of ways to merge them with efficacy values and produce efficacy reports so they are not strictly limited to being "safety" macros.

Options setting

If you intend to use the Spectre macro %pagexofy to add page labels then for %unistats and %npcttab to work correctly you should set the options noovp nodate nonumber. The "nodate" and "nonumber" are to ensure the "Page x of Y" labels can be added correctly (you can still have these labels added even if you are not using Spectre as will be explained below) and the "noovp" will stop the triple display of error messages in the log which is a nuisance. If you use Spectre then all these options are set in the %titles macro but if you are using these macros independently and not calling %titles then you will have to set these options yourself before making a call to these macros.

Avoid %openrep and %closerep

Both %openrep and %closerep are very Spectre-specific macros so you must not use these if you are running under Windows outside of Spectre. But you will need to do some of the things that %openrep is doing such as setting the options missing=" " and changing the formchar characters so if you are a Windows user then you will need to do this yourself in your code or write a different macro to do this. The %openrep macro calls "proc printto" to redirect the print output. This is so it can add page number labels to the output as a post-process using the %pagexofy macro. If you wish to add page labels in this manner then I presume you will need to do this as well. If you are not adding page labels then you do not need to redirect the output. You can look at the code of the macro below.
%openrep

The %closerep macro calls the macro %pagexofy to add the "Page x of Y" labels and to make some character substitutions such as changing the "A0"x character to spaces put there by %unistats for descriptive statistics decimal point alignment. If you are not adding page labels of the form "Page x of Y" then you do not need to call this macro. You have the choice with %pagexofy of overwriting the input file or specifying an output file. You must make sure you have freed the print file before you call this macro to overwrite it. If you have used a "proc printto" to redirect print output then you must cancel it with another call "proc printto print=print;" to free the output file before you call the %pagexofy macro to overwrite it. If you have allocated the print file using a filename statement then you must "clear" that fileref. Details of how to use the macro are in the header. Note that you must supply file names to this macro and not filerefs.
%pagexofy

"Page x of Y" labels

As mentioned in the previous section, you can use the macro %pagexofy to add "Page x of Y" labels to your output. If you are not adding page labels of this form then you need not use %pagexofy. What this macro is looking for is the character 'FF'x. This is known in Spectre as the "page marker". It assumes you have one of these per page and that you want the label to be put where this character is. The %titles macro calls a client titles macro to put these 'FF'x characters on a page but if you are not using %titles then you can still put these 'FF'x page markers there yourself. For some special situations you might need to do this in your code but if you want the page marker character to be on the top line on the far right then you can use the %latitle macro with the "pagemark=yes" option (for left-aligned titles) or the %ctitlepgmrk macro (for centred titles).
%latitle
%ctitlepgmrk

Example code for %unistats

This is an example piece of code for using %unistats and then calling the %pagexofy macro to turn the "þ" characters into spaces. Note that the output file must be freed before it can be converted "in-place". You will see I have redirected the print output back to its default destination in the "proc printto" statement, followed it by a "run" statement so that it takes effect before I deallocate the fileref with a "clear".
 
options noovp nodate nonumber center 
missing=" " formchar='|_---|+|---+=|-/\<>*'; 

options sasautos=("C:\spectre\macros" SASAUTOS); 

options ls=78 ps=63; 

%ctitlepgmrk("Centered title with a page marker on the right")
 

proc format; 
  value racecd 
  1="CAUCASIAN" 
  2="BLACK" 
  3="ASIAN" 
  4="HISPANIC" 
  5="OTHER" 
  ; 
  value sexcd 
  1="MALE" 
  2="FEMALE" 
  ; 
  value trtcd 
  1="Ambident (1g/day)" 
  2="Betamax (500mg/day)" 
  3="No treatment" 
  ; 
  value trtnarr 
  1="Ambident@(1g/day)" 
  2="Betamax@(500mg/day)" 
  3="No@treatment" 
  ;
  value NY 
  0="NO" 
  1="YES" 
  ; 
run;
 

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

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

filename tmp "roland.txt";
proc printto print=tmp new;

%unistats(dsin=demog,
descstats=N Min Mean Max STD., 
varlist=sexcd racecd age weight height);

proc printto print=print;
run;

filename tmp clear;

%pagexofy("roland.txt");

And here is "roland.txt" after being converted in-place by %pagexofy to change the "FF"x character to a page label.
 
                Centered title with a page marker on the right     Page 1 of 1
 
______________________________________________________________________________
 
                                      Ambident (1g/day)    Betamax (500mg/day)
                                            (N=9)                 (N=8)
______________________________________________________________________________
 
GENDER CODE
    MALE                                   4 ( 44.4)             3 ( 37.5)
    FEMALE                                 5 ( 55.6)             5 ( 62.5)
 
RACE CODE
    CAUCASIAN                              5 ( 55.6)             1 ( 12.5)
    BLACK                                  2 ( 22.2)             3 ( 37.5)
    ASIAN                                  2 ( 22.2)             3 ( 37.5)
    HISPANIC                               0 (  0.0)             0 (  0.0)
    OTHER                                  0 (  0.0)             1 ( 12.5)
 
AGE (YEARS)
    N                                      9                     8
    Min                                   16.0                  16.0
    Mean                                  26.3                  24.0
    Max                                   40.0                  36.0
    STD.                                   8.03                  8.49
 
WEIGHT (KG)
    N                                      9                     8
    Min                                   65.5                  65.5
    Mean                                  76.6                  70.8
    Max                                   79.6                  78.1
    STD.                                   4.36                  5.69
 
HEIGHT (CM)
    N                                      9                     8
    Min                                  175.0                 175.0
    Mean                                 197.2                 182.3
    Max                                  212.0                 200.0
    STD.                                  11.94                  9.00
 
 

Conclusion

%npcttab and %unistats can be used on Windows platforms independently of the Spectre reporting system and the way to do this has been explained on this page. If you are using these macros outside of the Spectre system on Unix then you should read the page on "Ad-hoc reporting" that you can link to below.
Ad-hoc Reporting and PDFs
 
 
 
 
 

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

contact the author