Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: FW: How to make 'contract' create a row of zerofrequencies?


From   Roger Harbord <[email protected]>
To   [email protected]
Subject   Re: st: FW: How to make 'contract' create a row of zerofrequencies?
Date   Mon, 22 May 2006 13:24:01 +0100

One solution could be to use -tabcount- by Nick Cox, available from SSC. You specify a list of values which define the categories of a variable that are to be counted, and zero frequencies are then included. The -replace- option makes it function much like -contract-, except zero frequencies are retained for the specified values.

Roger.


--On 22 May 2006 11:52 +0100 Pauline Rogers <[email protected]> wrote:


Dear All,

I have a large dataset containing information on individuals attending for
screening at several centres.

I am writing a program to summarise monthly attendance, to be run
regularly by one of our administrators.  So I first 'contract' my data to
create a new dataset of the number of attendances for each centre for
each month.  I used the following statement:

contract centre3 mrec, freq(count) zero

(Centre3 = centre code, mrec = month code)

I have discovered that when there are no attendances in a month at any of
the centres, Stata completely excludes this month rather than create a
zero count for each centre.

This then completely throws out my summary statistics.  Is there any way I
can force 'contract' to create a count of zero for each centre for any
month with zero attendance at all centres?
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index