Epi Info™ User Guide
Command Reference
Analysis Commands: GRAPH
Description
This command produces graphs from data in Classic Analysis.
Syntax
GRAPH [<variable(s)>] GRAPHTYPE=”<graph type>” [<option name>=option value]
GRAPH [<variable(s)>] * <crosstab> GRAPHTYPE=”<graph type>”
GRAPH [<variable(s)>] GRAPHTYPE=”<graph type>” XTITLE=”<string>” YTITLE=”<string>”
- The <variable(s)> represents the (main) variable(s) to be graphed.
- The <crosstab> represents a variable to be used to classify the main variable(s).
- The <graph type> represents one of the graph types described below.
- STRATAVAR=<variable> generates a graph for each value of VarName. When saving a template, the template stores the current graph’s background including the main title and the subtitle if it exists. However, if the sub-title is stratified (under “One Graph for Each Value of” in the dialog screen), it will be filtered out.
- WEIGHTVAR=<variable> weights each record by the value of <VarName>.
- WEIGHTVAR=<agg func>(<variable>) allows multiple records referring to the same values of the main variable, crosstab variable (if any), and strata variable (if any) are represented by the aggregate of VarName. Permissible AggFunc values are MIN (minimum), MAX (maximum), AVG (average), STDEV (standard deviation), SUM, SUMPCT (percent based on total of VarName), COUNT (number of records), or PERCENT (percent based on number of records).
- TITLETEXT=”<string>” represents a title for each page of graphs. This title is in addition to the title for each graph, which is set by customization.
- DATEFORMAT=”<format string>” is used when a main variable is a date variable to determine the format in which it will be displayed. Uses the same coding scheme as the FORMAT function.
- XTITLE=”<string>”, YTITLE=”<string>” are used to pass X- and Y-axis labels from the GRAPH command.
Program Specific Feature
Multiline (memo) fields cannot be graphed. To use a Multiline variable, define a new variable, assign to it the value SUBSTRING(<old variable>,1,255), and use it in the graph.
The following are the graph types capable of being generated by the GRAPH command along with type-specific information (“series” refers to the values of a main variable for a specific value of any crosstab and strata variables):
- Line graphs connect X-Y points with lines. The main variables are the X and Y variables. Each series is represented by a different style of line. Both variables must be numeric. To generate a line graph with categorical data, generate a Bar graph and use customization.
- Column graphs use vertical bars to represent the count or weight for each value of the main variable(s). Each series results in an additional vertical bar at each point; the bars are distinguished by their style.
- Bar graphs use horizontal bars to represent the count or weight of each value of the main variable(s). Each series creates an additional horizontal bar at each point.
- Epi Curve use vertical bars to represent the count or weight for each value of the main variable. Each series creates an additional vertical bar at each point. The main variable must be numeric. This graph differs from the bar graph because adjacent bars represent equal ranges of the main variable.
- Pie in which each series is represented by a circle, and each value of the main variable has a slice of the circle proportional to the value associated with it.
- Area is similar to a line, except that the area below the line contains a solid fill.
- Scatter graphs display X-Y points as a scatter gram. The main variables are X and Y variables. Each series is represented by a different style of point.
- Bubble graphs are a variation of a Scatter chart in which the data points are replaced with bubbles. A Bubble chart can be used instead of a Scatter chart if your data has three data series. Each data series in a chart has a unique color and is represented in the chart legend.
Examples
Example 1: A graph showing the age of all survey respondents is displayed.
READ {.\Projects\Sample\Sample.prj}:Oswego GRAPH Age GraphType="Column"
Example 2: A pie chart showing age categories is displayed.
READ {.\Projects\Sample\Sample.prj}:Oswego DEFINE AgeCategory TEXTINPUT RECODE Age TO AgeCategory LOVALUE - 0 = "Unknown" 0 - 10 = "0 - 10" 10 - 20 = "11 - 20" 20 - 30 = "21 - 30" 30 - 50 = "31 - 50" 50 - 70 = "51 - 70" 70 - HIVALUE = ">70" END GRAPH AgeCategory GRAPHTYPE="Pie" TITLETEXT="Church Supper Attendees"
Example 3: A scatter graph is displayed showing age by time of supper.
READ {.\Projects\Sample\Sample.prj}:Oswego GRAPH TimeSupper Age GRAPHTYPE="Scatter"
Example 4: A graph showing the number of ill persons and vanilla eaters is displayed using the form for the Oswego outbreak investigation.
READ {.\Projects\Sample\Sample.prj}:Oswego FREQ Vanilla Ill STRATAVAR=Sex OUTTABLE=VanillaOut READ {.\Projects\Sample\Sample.prj}:VanillaOut SELECT Vanilla = (+) OR Ill = (+) SET Missing = (-) DEFINE Vanilla2 YN DEFINE Ill2 YN IF Ill = (+) THEN ASSIGN Ill2 = Sex END IF Vanilla = (+) THEN ASSIGN Vanilla2 = Sex END GRAPH Ill2 Vanilla2 GRAPHTYPE="Bar" TITLETEXT="Number of Ill Persons and Vanilla Eaters by Sex" WEIGHTVAR=Count
Example 5: An Epi Curve showing the incubation time for an unknown pathogen is displayed. Note that the DIALOG=(-) parameter ensures the graph window does not appear. Instead, the graph is generated and sent to the Analysis output window. This option can be useful when running automated scripts since it does not require user interaction to continue processing commands.
READ {.\Projects\Sample\Sample.prj}:Oswego DEFINE Incubation NUMERIC ASSIGN Incubation = MINUTES(TimeSupper, DateOnset) / 60 GRAPH Incubation GRAPHTYPE="Epi Curve" XTITLE="Incubation Period (Hours)" YTITLE="Number of Cases"