[EpiData-list] Grouping for frequency tables
epidata-list at lists.umanitoba.ca
epidata-list at lists.umanitoba.ca
Tue Nov 27 19:17:03 CST 2007
There is a way to do this, using CMD as was documented in EpiInfo. This
has not yet been documented for Epidata, but it works.
I have attached two sample PGM files that you can adapt. I don't have a
good test file this at hand. These short files will show you the
principles behind CMD and how to use GLOBAL variables the /q (quiet)
option and the TYPE command to do what you are asking.
MultiFreq.pgm uses plain text output
MultiFreqHTML.pgm uses simple HTML to format the output into a table
This kind of pgm was common in EpiInfo v6, but takes a reasonable
understanding of programming concepts.
The great thing is that you can do this once and adapt it for many uses.
You could also do with without the CMD parts by hard coding the quiet
determination of numerators and %s for each symptom as in the third pgm
(MultiFreqBruteForce.pgm)
(I haven't tested that one)
Jamie
Christine wrote:
> In our outbreak reports we want tables that show the count and percent
> of sick people with a range of symptoms - for example (say with 20
> people ill)
>
> diarrhoea 20 100%
> Vomiting 10 50%
> Fever 5 25%
>
> At the moment I create a frequency table for each symptom and then cut
> and paste them into one summary table. I would like to know if there is
> a quick way to create just one symptoms table
>
-------------- next part --------------
set echo=off
** Produce a table of frequencies of symptoms reported
**************************************************
** Example of creating symptom table in EpiData **
** Must be adapted to your data set **
** Programming: Jamie Hockin **
** November 2007 Analysis V2 **
** Change lines with //* comments at the end **
**************************************************
define avar ____________ global
define acount <Y> global //* change <Y> to match variable type
select ill = TRUE //* select only cases, if necessary
avar = "ill" //* change "ill" to match case variable, or any other that will provide denominator
denom
acount = "Y" //* change to match type and code for symptom="yes"
avar = "vomit" //* change "vomit" to match first symptom variable name
afreq
avar = "cramps" //* etc
afreq
avar = "diarrhea" //*
afreq
type "</table>"
select
set echo=on
** Two short commands that do the work **
cmd denom // denom counts the denominator
type "<table>"
type "<tr><td>Variable</td><td>Freq</td><td>%</td></tr>" // and prints the header
define adenom ###### global // adenom holds denominator
define adiv2 ###### global // adiv2 holds denominator/2 for rounding %s
define apct ### global // apct will be the calculated %
freq @avar /q
adenom = $total1 // and save it here
adiv2 = adenom div 2
end
cmd afreq // afreq calculates one frequency and %
freq @avar /q if @avar="@acount" // frequency of a symptom, where value is acount (i.e. "yes")
apct = (100*$total1 + adiv2) div adenom // round off percent (could have apct as ###.## and get decimals)
type "<tr><td>@avar</td><td>@$total1</td><td>@apct%</td></tr>" // print the line
end
-------------- next part --------------
** Produce a table of frequencies of symptoms reported
**************************************************
** Example of creating symptom table in EpiData **
** Must be adapted to your data set **
** Programming: Jamie Hockin **
** November 2007 Analysis V2 **
** Change lines with //* comments at the end **
**************************************************
set echo=off
define avar ____________ global
define acount <Y> global //* change <Y> to match variable type
select ill = TRUE //* select only cases, if necessary
avar = "ill" //* change "ill" to match case variable, or any other that will provide denominator
denom
acount = "Y" //* change to match type and code for symptom="yes"
avar = "vomit" //* change "vomit" to match first symptom variable name
afreq
avar = "cramps" //* etc
afreq
avar = "diarrhea" //*
afreq
select
** Two short commands that do the work **
cmd denom // denom counts the denominator
type "Variable Freq %" // and prints the header
define adenom ###### global // adenom holds denominator
define adiv2 ###### global // adiv2 holds denominator/2 for rounding %s
define apct ### global // apct will be the calculated %
freq @avar /q
adenom = $total1 // and save it here
adiv2 = adenom div 2
end
cmd afreq // afreq calculates one frequency and %
freq @avar /q if @avar="@acount" // frequency of a symptom, where value is acount (i.e. "yes")
apct = (100*$total1 + adiv2) div adenom // round off percent (could have apct as ###.## and get decimals)
type "@avar @$total1 @apct%" // print the line
end
-------------- next part --------------
** Produce a table of frequencies of symptoms reported
**************************************************
** Example of creating symptom table in EpiData **
** Must be adapted to your data set **
** Programming: Jamie Hockin **
** November 2007 Analysis V2 **
**************************************************
set echo=off
define adenom ###### global // adenom holds denominator
define adiv2 ###### global // adiv2 holds denominator/2 for rounding %s
define apct ### global // apct will be the calculated %
select ill = TRUE //* select only cases, if necessary
freq ill /q
adenom = $total1
adiv2 = adenom div 2
type "Variable N %"
freq vomit /q if vomit // if <Y> variable
apct = (100*$total1 + adiv2) div adenom
type "vomit @$total1 @apct%"
freq cramps /q if cramps // if <Y> variable
apct = (100*$total1 + adiv2) div adenom
type "cramps @$total1 @apct%"
freq diarrhea /q if diarrhea // if <Y> variable
apct = (100*$total1 + adiv2) div adenom
type "diarrhea @$total1 @apct%"
More information about the EpiData-list
mailing list