Have a personal or library account? Click to login
%svy_freqs: A Generic SAS Macro for Creating Publication-Quality Three-Way Cross-Tabulations Cover

%svy_freqs: A Generic SAS Macro for Creating Publication-Quality Three-Way Cross-Tabulations

Open Access
|Oct 2021

Figures & Tables

Table 1

Input parameters for %svy_freqs macro.

PARAMETERDESCRIPTION
_dataname of input dataset
_factorslist of categorical variables separated by space
_cat_typetype of analysis for categorical variables i.e., COL for column percentages, ROW for row percentages, PREV for prevalence percentages
_contvarslist of continuous variables separated by space
_cont_typetype of analysis for continuous variables i.e., MEAN or MEDIAN
_byvarname of categorical by-group variable which can have any number of categories/levels
_outcome(optional) name of third variable for which cross-tabulations are needed e.g., lbxha, for Hepatitis A, but must be specified if prevalence analysis is being performed
_outvalue(optional) value label of third variable to compute prevalence cross-tabulation but must be specified if _outcome is specified e.g., Positive, in the case of prevalence of Hepatitis A.
_strata(optional) survey stratification variable
_cluster(optional) survey clustering variable
_weight(optional) survey weighting variable
_domain(optional) domain variable for sub-population analysis
_domainvalue(optional) value of domain/sub-population of interest (should be numeric). Required if _domain is specified
_varmethod(optional) value for variance estimation method namely Taylor (the default) or replication-based variance estimation methods including JK or BRR
_varmethod_opts(optional) options for variance estimation method, e.g., jkcoef = 1 df = 25 for JK
_rep_weights_values(optional) values for REPWEIGHTS statement, but may be specified with replication-based variance estimation method is JK or BRR
_missval_lab(optional) value label for missing values. If missing data have a format, it should be provided, otherwise macro assumes the default format “.”
_missval_opts(optional) options for handling missing data within proc survey statement, e.g., “MISSING” or “NOMCAR”. If no option is specified all missing observations are excluded from the analysis
_idvarname of unique identifying variable
_condition(optional) any conditional statements to create and or fine-tune the final analysis dataset specified using one IF statement
_outdirpath for directory/folder where output is saved
_tablenameshort name of output table
_tabletitletitle of output table
_surveynameabbreviation for survey/study to be included in the output
_printvariable for displaying/suppressing the output table on the output window which takes the values (NO = suppress output, YES = show output)
Table 2

Participants’ socio-demographic characteristics by sex (Col %), N = 522π.

CHARACTERISTIC£MALEFEMALETOTAL
UNWEIGHTED N@WEIGHTED % (OR MEDIAN)¥95% CL (OR IQR)$UNWEIGHTED NWEIGHTED % (OR MEDIAN)95% CL (OR IQR)UNWEIGHTED NWEIGHTED % (OR MEDIAN)95% CL (OR IQR)
Age in years at screening
    20–394612.7(7.9–17.5)619.2(2.8–35.6)5213.3(8.6–18.0)
    40–5911425.2(19.9–30.5)2461.8(38.2–85.3)13828.3(21.4–35.2)
    >= 606032662.1(56.0–68.1)619.1(2.2–35.9)33258.4(51.5–65.4)
    Total486100(__–__)36100(__–__)522100(__–__)
Race/Hispanic origin
    Mexican American232.6(0.7–4.5)0.(.–.)232.4(0.7–4.1)
    Other Hispanic253.2(1.6–4.8)22.9(0.0–7.5)273.2(1.5–4.8)
    Non-Hispanic White29680.1(74.0–86.2)1668.3(52.4–84.3)31279.1(73.1–85.2)
    Non-Hispanic Black11510.2(6.4–14.0)1727.7(14.3–41.1)13211.6(7.8–15.5)
    Other Race273.9(1.5–6.2)11.1(0.0–3.6)283.6(1.5–5.8)
    Total486100(__–__)36100(__–__)522100(__–__)
Served in a foreign country
    Yes26152.4(46.2–58.6)1436.8(18.7–54.9)27551.1(45.7–56.5)
    No22447.6(41.4–53.8)2263.2(45.1–81.3)24648.9(43.5 –54.3)
    Missing10.6(0.0–2.0)0.(.–.)10.6(0.0–1.8)
    Total486100(__–__)36100(__–__)522100(.–.)
Hepatitis A antibody
    Positive20537.7(34.0–41.4)1539.7(18.0–61.3)22037.9(34.8–40.9)
    Negative26862.3(58.6–66.0)2060.3(38.7–82.0)28862.1(59.1–65.2)
    Missing131.7(0.7–2.7)12.1(0.0–6.0)141.7(0.8–2.7)
    Total486100(__–__)36100(__–__)522100(__–__)
Median age in years at screening48664.2(51.3–73.0)3650.3(41.1–53.8)52263.5(49.5–72.2)

[i] π = Analysis domain sample size.

€ = By-group variable.

£ = column for listing factor variables labels and corresponding categories.

@ = column for listing raw frequencies.

¥ = column for listing weighted column/row/prevalence % (for categorical factors) or median/mean (for continuous factors).

$ = column for weighted 95% confidence interval (for column/row/prevalence/mean % estimates) or interquartile range, IQR (for median estimates).

Table 3

Socio-demographic characteristics by Hepatitis A status (Row %), N = 522.

CHARACTERISTICPOSITIVENEGATIVEMISSING
UNWEIGHTED N/NWEIGHTED % (OR MEDIAN)95% CL (OR IQR)UNWEIGHTED N/NWEIGHTED % (OR MEDIAN)95% CL (OR IQR)UNWEIGHTED N/NWEIGHTED % (OR MEDIAN)95% CL (OR IQR)
Gender
    Male205/48637.1(33.6–40.6)268/48661.2(57.3–65.2)13/4861.7(0.7–2.7)
    Female15/3638.9(17.3–60.4)20/3659.0(38.2–79.9)1/362.1(0.0–6.0)
    Total220/52237.2(34.4–40.1)288/52261.0(57.7–64.4)14/5221.7(0.8–2.7)
Age in years at screening
    20–3939/5282.4(72.6–92.2)12/5216.9(7.1–26.7)1/520.7(0.0–2.3)
    40–5950/13830.8(23.1–38.5)85/13867.9(59.7–76.1)3/1381.3(0.0–2.6)
    >= 6060131/33230.1(25.3–34.9)191/33267.7(62.4–73.1)10/3322.2(0.4–3.9)
    Total220/52237.2(34.4–40.1)288/52261.0(57.7–64.4)14/5221.7(0.8–2.7)
Race/Hispanic origin
    Mexican American14/2367.1(41.3–92.8)9/2332.9(7.2–58.7)0/23.(.–.)
    Other Hispanic17/2762.1(30.6–93.6)9/2734.5(5.5–63.6)1/273.3(0.0–11.2)
    Non-Hispanic White114/31233.7(30.3–37.2)193/31265.1(61.1–69.0)5/3121.2(0.0–2.3)
    Non-Hispanic Black59/13244.1(35.7–52.4)67/13251.5(42.8–60.1)6/1324.5(1.1–7.8)
    Other Race-Racial16/2849.6(23.2–76.1)10/2845.2(15.1–75.2)2/285.2(0.0–11.6)
    Total220/52237.2(34.4–40.1)288/52261.0(57.7–64.4)14/5221.7(0.8–2.7)
Served in a foreign country
    Yes134/27547.3(41.2–53.4)130/27550.0(43.5–56.6)11/2752.7(0.9–4.6)
    No86/24627.2(18.4–35.9)157/24672.1(63.1–81.1)3/2460.7(0.0–1.7)
    Missing0/1.(.–.)1/1100(.–.)0/1.(.–.)
    Total220/52237.2(34.4–40.1)288/52261.0(57.7–64.4)14/5221.7(0.8–2.7)
Table 4

Distribution of Hepatitis A prevalence by selected socio-demographic characteristics and sex (Prevalence %), N = 522.

CHARACTERISTICMALEFEMALETOTAL
UNWEIGHTED N/NWEIGHTED PREV. %95% CLUNWEIGHTED N/NWEIGHTED PREV. %95% CLUNWEIGHTED N/NWEIGHTED PREV. %95% CL
Age in years at screening
    20–3936/4686.4(76.0–96.7)3/653.3(1.0–100)39/5282.4(72.6–92.2)
    40–5942/11431.4(22.4–40.3)8/2428.4(7.5–49.3)50/13830.8(23.1–38.5)
    >= 6060127/32629.3(24.8–33.7)4/658.3(7.9–100)131/33230.1(25.3–34.9)
    Total205/48637.1(33.6–40.6)15/3638.9(17.3–60.4)220/52237.2(34.4–40.1)
Race/Hispanic origin
    Mexican American14/2367.1(41.3–92.8)0/0.(.–.)14/2367.1(41.3–92.8)
    Other Hispanic15/2558.9(24.9–93.0)2/2100(.–.)17/2762.1(30.6–93.6)
    Non-Hispanic White108/29633.6(29.2–37.9)6/1636.0(9.1–62.8)114/31233.7(30.3–37.2)
    Non-Hispanic Black53/11545.8(35.6–55.9)6/1737.2(14.3–60.2)59/13244.1(35.7–52.4)
    Other Race15/2748.3(21.5–75.2)1/1100(.–.)16/2849.6(23.2–76.1)
    Total205/48637.1(33.6–40.6)15/3638.9(17.3–60.4)220/52237.2(34.4–40.1)
Served in a foreign country
    Yes127/26146.6(39.8–53.3)7/1458.2(29.1–87.3)134/27547.3(41.2–53.4)
    No78/22427.1(17.9–36.3)8/2227.6(2.1–53.1)86/24627.2(18.4–35.9)
    Missing0/1.(.–.)0/0.(.–.)0/1.(.–.)
    Total205/48637.1(33.6–40.6)15/3638.9(17.3–60.4)220/52237.2(34.4–40.1)
jors-9-318-g1.pngjors-9-318-g2.png
Example 1

Sample %svy_freqs macro call to output column percentages.

jors-9-318-g3.pngjors-9-318-g4.png
Example 2

Sample %svy_freqs macro call to output row percentages.

jors-9-318-g5.pngjors-9-318-g6.png
Example 3

Sample %svy_freqs macro call to output prevalence percentages.

DOI: https://doi.org/10.5334/jors.318 | Journal eISSN: 2049-9647
Language: English
Submitted on: Jan 29, 2020
|
Accepted on: Oct 6, 2021
|
Published on: Oct 22, 2021
Published by: Ubiquity Press
In partnership with: Paradigm Publishing Services
Publication frequency: 1 issue per year

© 2021 Jacques Muthusi, Peter W. Young, Samuel Mwalili, published by Ubiquity Press
This work is licensed under the Creative Commons Attribution 4.0 License.