/******************* URBAN INSTITUTE MACRO LIBRARY *********************
: Moe_ratio
Macro: Autocall macro that returns a calculation for a margin of error
Descriptionfor a derived ratio based on the values and margins of error of the
proportion numerator and denominator.
The numerator of a ratio is NOT a subset of the denominator
(e.g., the ratio of females living alone to males living alone).
: Function
Use
: Peter Tatian
Author
***********************************************************************/
Moe_ratio(
%macro num=, /** Ratio numerator value **/
den=, /** Ratio denominator value **/
num_moe=, /** Numerator margin of error **/
den_moe= /** Denominator margin of error **/
);
/*************************** USAGE NOTES *****************************
:
SAMPLE CALLmoe_ratio( num=female, den=male, num_moe=female_moe, den_moe=male_moe )
%for margin of error for ratio female/male
returns calculation *********************************************************************/
/*************************** UPDATE NOTES ****************************
09/23/11 Peter A. Tatian
*********************************************************************/
***** ***** ***** MACRO SET UP ***** ***** *****;
%
%local ratio;
***** ***** ***** ERROR CHECKS ***** ***** *****;
%
***** ***** ***** MACRO BODY ***** ***** *****;
%
= ((&num)/(&den));
%let ratio
sqrt( ((&num_moe)*(&num_moe)) + ((&ratio*&ratio) * ((&den_moe)*(&den_moe))) ) / (&den))
(
***** ***** ***** CLEAN UP ***** ***** *****;
%
%mend Moe_ratio;
/************************ UNCOMMENT TO TEST ***************************
options mprint;
data _null_;= 45/55;
ratio = %moe_ratio( num=45, den=55, num_moe=10, den_moe=8 );
moe = moe=;
put ratio
run;/**********************************************************************/
MOE from Derived Ratio
Purpose: Autocall macro that returns a calculation for a margin of error for a derived ratio based on the values and margins of error of the proportion numerator and denominator.
The numerator of a ratio is NOT a subset of the denominator (e.g., the ratio of females living alone to males living alone).