%macro moeratio(rvar,moenum,moeden,den,pct=1) ; %*--Untility macro used to calculate the MOE of a ration or percentage. Args passed are the ratio/pct variable, the moe values for the numerator and denominator used to derive the ratio, and the MOE of the denominator variable. A pct flag parm defaults to 1 (true) indicating that rvar is a percentage. We used this to adjust the formula to calculate the moe of the percentage without the 100 factor, but then multiply the result by 100. The macro generates code to assign an moe estimate to variable formed by appending _moe to name of rvar. Uses a temp variable __ratiovar which should be dropped in invoking data step. We use the pct flag parm to indicate if the ratio var is a percentage. From formula in App A, pp. A-14,15, A Compass for using ACS data, Aug., 2009. Sample: moeratio(pctpoorover65,poorover65_moe,povuniverseOver65_moe,PovUniverseOver65) results in a value being assigned to pctpoorover65_moe measuring the moe for variable pctpoorover65. ---; %let moevar=&rvar._moe; if &den <= 0 then &moevar = .; else do; %if &pct %then %str( __ratiovar=.01*&rvar;) ; %else %str( __ratiovar=&rvar; ); &moevar= sqrt( &moenum**2 - (__ratiovar**2 * &moeden**2) ) / &den ; %if &pct %then %do; &moevar=100*&moevar; %end; end; %mend moeratio;