Static vs. dynamic variables
It's useful to distinguish between variables containing information that
is constant within a cluster and those where the information can change
within a cluster. We call these static and dynamic variables
respectively.
In our example dataset idnum, sex and region are static variables, whilst all
others are dynamic (date, sbp and beta).
The default behaviour of xtab is to tabulate the number of clusters where a value has ever appeared. This produces the kind of table we would naturally expect for static variables, like those we've already seen for sex and region. Missing values are ignored unless we specifically ask for them with the missing option.
When using xtab on dynamic variables, we need to remember that by default xtab is in 'ever' mode to interpret the output correctly:
Here we see that the numbers in the Yes and No categories of beta-blocker use sum to more than the total of 15. This is because some patients have either started or stopped using beta-blockers during the follow-up period. What we can say is that about a quarter of patients have used beta-blockers at some time during the trial. We might be interested in knowing how many patients have not taken beta-blockers at all during the trial:
So 11 patients have no experience of beta-blockers. The occasion() option can also be used to tabulate a particular record within the cluster. This is only relevant for dynamic variables. A common summary is of patient characteristics at baseline:
Notice that the t() option is required since xtab needs to know how records are to be ordered within cluster to be able to choose the first record. The time variable can be specified in advance allowing the t() option to be omitted from xtab:
. tis date
. xtab beta, occasion(1)
The number of patients using beta-blockers at the end of the trial can be identified with the occasion(last) option:
We can see that the beta-blocker variable is missing for most patients on the last follow-up visit. Two patients were followed-up only once or twice. Tabulating beta-blocker use at the third follow-up visit therefore excludes these two patients from the total:
net from http://www.sealedenvelope.com/
and follow the instructions on screen. This will ensure the files are installed in the right place and you can easily uninstall the command later if you wish.