Changeset 19744 in main
- Timestamp:
- 01/24/20 16:58:21 (3 years ago)
- Location:
- adopters/mt/trunk/src/main/backend_qModules/birth23
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
adopters/mt/trunk/src/main/backend_qModules/birth23/MT_Average_data_frame.def
r19478 r19744 25 25 ?cross2? %cross2% 26 26 ; 27 format mean 5.2 count 9.0 sum 9.0 stderr 6.2;27 *format mean 5.2 count 9.0 sum 9.0 stderr 6.2; 28 28 output out=tmp mean=mean n=count sum=sum stderr=stderr; 29 29 run; … … 89 89 * the numerator and denominator counts for the cell suppression. ; 90 90 *****************************************************************; 91 %let flag=0; 92 ?popcross1? %let flag=1; 93 ?popcross2? %let flag=1; 94 ?popcross1? ?popcross2? %let flag=2; 95 96 %macro popcross; 97 98 %if &flag=0 %then %do; 99 proc summary data=poptmp; 100 var popcount; 101 output out=pop sum=popcount; 102 run; 103 proc sql; 104 create table rate as 105 select tmp.*, pop.* 106 from tmp, pop 107 quit; 108 %end; 109 110 %if &flag=1 %then %do; 111 proc summary data=poptmp; 112 var popcount; 113 class %popcross1% %popcross2%; 114 output out=pop sum=popcount; 115 run; 116 data pop; 117 set pop; 118 rename 119 ?popcross1? %popcross1%=%cross1% 120 ?popcross2? %popcross2%=%cross2% 121 ; 122 drop _TYPE_ _FREQ_ ; 123 run; 124 proc sort data=pop; 125 ?popcross1? by %cross1%; 126 ?popcross2? by %cross2%; 127 run; 128 proc sort data=tmp; 129 ?popcross1? by %cross1%; 130 ?popcross2? by %cross2%; 131 run; 132 proc print data=pop noobs; title2 '3. POP - pop dataset'; run; 133 data rate; 134 merge tmp pop; 135 ?popcross1? by %cross1%; 136 ?popcross2? by %cross2%; 137 run; 138 %end; 139 140 %if &flag=2 %then %do; 141 proc summary data=poptmp; 142 var popcount; 143 class %popcross1% %popcross2% ; 144 output out=pop sum=popcount; 145 run; 146 data pop; 147 set pop; 148 rename %popcross1%=%cross1% %popcross2%=%cross2% ; 149 run; 150 proc sort data=pop; 151 by %cross1% %cross2%; 152 run; 153 proc sort data=tmp; 154 by %cross1% %cross2%; 155 run; 156 data rate; 157 merge tmp pop; 158 by %cross1% %cross2% 159 ; 160 run; 161 %end; 162 %mend; 163 %popcross; 164 165 ********************** 4. tmp, again ****************************; 166 * Create the output variables for the IBIS xml/map file. ; 167 *****************************************************************; 168 data tmp; 169 set rate; 170 171 *****************************************************************; 172 * Student's t distribution. df=count-1. The "Z" value is really ; 173 * the critical value of "t", two tailed, with an alpha of 0.025. ; 174 *****************************************************************; 175 if count=1 then Z= .; 176 else if count=2 then Z= 12.706; 177 else if count=3 then Z= 4.303; 178 else if count=4 then Z= 3.182; 179 else if count=5 then Z= 2.776; 180 else if count=6 then Z= 2.571; 181 else if count=7 then Z= 2.447; 182 else if count=8 then Z= 2.365; 183 else if count=9 then Z= 2.306; 184 else if count=10 then Z= 2.262; 185 else if count=11 then Z= 2.228; 186 else if count=12 then Z= 2.201; 187 else if count=13 then Z= 2.179; 188 else if count=14 then Z= 2.160; 189 else if count=15 then Z= 2.145; 190 else if count=16 then Z= 2.131; 191 else if count=17 then Z= 2.120; 192 else if count=18 then Z= 2.110; 193 else if count=19 then Z= 2.101; 194 else if count=20 then Z= 2.093; 195 else if count=21 then Z= 2.086; 196 else if count=22 then Z= 2.074; 197 else if count=23 then Z= 2.069; 198 else if count=24 then Z= 2.064; 199 else if count=25 then Z= 2.060; 200 else if count=26 then Z= 2.056; 201 else if count=27 then Z= 2.052; 202 else if count=28 then Z= 2.048; 203 else if count=29 then Z= 2.045; 204 else if count=30 then Z= 2.042; 205 else if count>30 then Z= 1.96; 206 207 t1=mean-(Z*stderr); 208 if (t1<0) then t1=0; 209 if count in (0 1) then t1=.; 210 LL=put(t1, 8.2); 211 UL=put((mean+(z*stderr)), 8.2); 212 LL=compress(LL); 213 UL=compress(UL); 214 n=count; *ibis-q needs a count variable named 'n'; 215 216 217 proc print data=tmp; title2 '4. tmp again - t1=mean*stderr, LL,UL,n before suppression'; 91 %let flag=0; 92 ?popcross1? %let flag=1; 93 ?popcross2? %let flag=1; 94 ?popcross1? ?popcross2? %let flag=2; 95 96 %macro popcross; 97 98 %if &flag=0 %then %do; 99 proc summary data=poptmp; 100 var popcount; 101 output out=pop sum=popcount; 102 run; 103 proc sql; 104 create table rate as 105 select tmp.*, pop.* 106 from tmp, pop 107 quit; 108 %end; 109 110 %if &flag=1 %then %do; 111 proc summary data=poptmp; 112 var popcount; 113 class %popcross1% %popcross2%; 114 output out=pop sum=popcount; 115 run; 116 proc sql; 117 create table rate as 118 select tmp.*, pop.* 119 from tmp, pop 120 where 121 ?popcross1? tmp.%cross1%=pop.%popcross1%; 122 ?popcross2? tmp.%cross2%=pop.%popcross2%; 123 quit; 124 %end; 125 126 %if &flag=2 %then %do; 127 proc summary data=poptmp; 128 var popcount; 129 class %popcross1% %popcross2% ; 130 output out=pop sum=popcount; 131 run; 132 proc sql; 133 create table rate as 134 select tmp.*, pop.* 135 from tmp, pop 136 where tmp.%cross1%=pop.%popcross1% and 137 tmp.%cross2%=pop.%popcross2%; 138 quit; 139 %end; 140 %mend; 141 %popcross; 142 proc print data=rate noobs; title2 '3. merged tmp and pop prior to cell suppression'; 218 143 run; 219 220 ********************** 5. tmp, again Redflag and cell suppression *************;144 145 ********************** 4. tmp, again Redflag and cell suppression *************; 221 146 * Create the output variables for the IBIS xml/map file. ; 222 147 * Add Redflag ; … … 227 152 * ; 228 153 * And Apply Montana specific Small numbers rules as follows ; 229 * 1. Suppress cells if absolute count <5 ; 230 * 2. Suppress complimentarty cells if you can arrive at the ; 231 * number in a cell less than 5 by subtraction ; 232 * Note: I think we just suppress everything in case #2 ; 233 * 3. do not compute rates based on fewer than 20 events. ; 234 * This would include rates like deaths per 100,000, low birth ; 235 * weight as % of live births, or ratios like maternal mortality ; 236 * per 100 live births. ; 237 * Note: for crude rates if 20 <=count<100 would use Poisson, ; 238 * for computing confidence intervals but according to Cody this does ; 239 * not apply for avgs - all confidence intervals using T-distribution ; 240 * which already adjusts for small n ; 241 * ZW-s program uses ".A" to identify cells for suppression. ; 154 * (Comments include rulse for Vital Statistics Counts and Rates( ; 155 * 1. If denominator (popcount > 300) ; 156 * 1a. If count <5 ; 157 * Suppress cells ; 158 * 1b. Suppress complimentarty cells if you can arrive at the ; 159 * number in a cell less than 5 by subtraction ; 160 * Note: I think we just suppress everything in case #1a and 1b ; 161 * 2. If count > 5 and < 20 ; 162 * Suprss rates, but compute counts ; 163 * This would include rates like deaths per 100,000, low birth ; 164 * weight as % of live births, or ratios like maternal mortality ; 165 * per 100 live births. ; 166 * if 20<=count<=100 (events between 20 and 100) ; 167 * (according to Cody this does not apply for avgs?? ; 168 * 2. If denominater (popcount < 300) ; 169 * 2a. If count > 20 ; 170 * Report count and rates with confidence intervals ; 171 * 2b. If count > 20 ; 172 * Suppress rates and counts ; 173 * ZW-s program uses ".A" to identify cells for suppression. ; 242 174 * I have co-opted his method so I can use the MT logic for cell ; 243 175 * suppression instead of the standard IBIS logic. And I need to use ; … … 248 180 *******************************************************************************; 249 181 250 data tmp; 251 set tmp; 252 n=count; *ibis-q needs a count variable named 'n'; 253 254 182 **************** ASK LOIS ABOUT STDERR COMPUTATIONS ***************************; 183 184 data tmp; 185 set rate; 186 n=count; *ibis-q needs a count variable named 'n'; 187 188 255 189 if popcount>=300 then do; 256 257 * Suppress cells if absolute count <5 190 191 * Suppress cells if absolute count <5 ; 258 192 259 193 if 1<=count<5 then do; 260 mean =.A;261 LL= put('**', 15.0);262 UL= put('**', 15.0);194 mean=.A; 195 LL=.A; 196 UL=.A; 263 197 redflag=put('Suppressed', $15.); 264 198 n=.A; 265 199 end; 266 267 * do not compute rates based on fewer than 20 events, but provide counts;200 201 * do not compute rates based on fewer than 20 events, but provide counts; 268 202 269 203 if 5<=count<20 then do; 270 204 mean=.A; 271 LL= put('**', 15.0);272 UL= put('**', 15.0);205 LL=.A; 206 UL=.A; 273 207 redflag=put('Suppressed Rate', $16.); 274 208 end; 275 209 276 if count=>20 then do; 277 * NOTE, According to CODY, since using T-distribution, no need to; 278 * Poisson, but need to check with MT ; 210 if 20<=count<=100 then do; 211 * for events between 20 and 100, use Poisson to calculate confidence intervals; 212 213 t1= GAMINV(.025,count)/popcount*1000; 214 if (t1<0) then t1=0; 215 LL=put(t1, 8.2); 216 UL=put(( GAMINV(.975,count)/popcount*1000),8.2); 217 end; 218 219 * and normal approximation for more than 100 events. ; 220 221 if count>100 then do; 222 t1=(mean-(1.96*stderr)); 223 if (t1<0) then t1=0; 224 LL=put(t1, 8.2); 225 UL=put((mean+(1.96*stderr)), 8.2); 226 LL=compress(LL); 227 UL=compress(UL); 279 228 redflag=put('-', $15.); 280 229 end; … … 284 233 285 234 * suppress if popcount <300 and count < 20 events. ; 286 if count <20 then do; 235 236 if 1<=count<20 then do; 287 237 mean=.A; 288 LL= put('**', 15.0);289 UL= put('**', 15.0);290 redflag=put('Suppressed', $1 6.);238 LL=.A; 239 UL=.A; 240 redflag=put('Suppressed', $15.); 291 241 n=.A; 292 242 end; 293 243 294 * report rate and n if popcount <300 and count >= 20 events. ; 295 if count=>20 then do; 244 245 * report rate and n if popcount <300 and count >= 20 events. ; 246 247 if 20<=count<=100 then do; 248 * for events between 20 and 100, use Poisson to calculate confidence intervals; 249 250 *mean=(rate*1000); 251 t1= GAMINV(.025,count)/popcount*1000; 252 if (t1<0) then t1=0; 253 LL=put(t1, 8.2); 254 UL=put(( GAMINV(.975,count)/popcount*1000),8.2); 255 end; 256 257 * and normal approximation for more than 100 events. ; 258 259 if count>100 then do; 260 t1=(mean-(1.96*stderr)); 261 if (t1<0) then t1=0; 262 LL=put(t1, 8.2); 263 UL=put((mean+(1.96*stderr)), 8.2); 264 LL=compress(LL); 265 UL=compress(UL); 296 266 redflag=put('-', $15.); 297 267 end; 298 268 end; 299 269 300 if count<=0 then do; 301 redflag=put('No Variance', $15.); *no variance, n=0; 302 n=count; *ibis-q needs a count variable named 'n'; 270 if count=0 then do; 271 mean=.A; 272 LL=.A; 273 UL=.A; 303 274 end; 304 305 proc print data=tmp noobs; title2 '6. TMP - final dataset to pass to IBIS View app'; 275 276 if count<0 then do; 277 mean=0; 278 mean=.A; 279 LL=.A; 280 UL=.A; 281 redflag=put('No Variance', $15.); *no variance; 282 end; 283 284 proc print data=tmp; title2 '4. tmp again - output variables for the IBIS xml/map and Redflag and cell suppression'; 306 285 run; 307 286 308 287 --------BoNdArY-------- 309 288 # definition for output file … … 313 292 f out_detail lbl_not_used__see_xml_out_map_file 314 293 mean 15.2 315 n 15. 0316 LL 15. 317 UL 15. 294 n 15.2 295 LL 15.2 296 UL 15.2 318 297 redflag 16.0 319 298 --------BoNdArY-------- … … 333 312 --------BoNdArY-------- 334 313 1 suppressed_variables 4 335 336 337 338 339 --------BoNdArY-------- 314 mean 315 n 316 LL 317 UL 318 --------BoNdArY-------- -
adopters/mt/trunk/src/main/backend_qModules/birth23/MT_Count_data_frame.def
r19478 r19744 170 170 * ; 171 171 * And Apply Montana specific Small numbers rules as follows ; 172 * 1. Suppress cells if absolute count <5 ; 173 * 2. Suppress complimentarty cells if you can arrive at the ; 174 * number in a cell less than 5 by subtraction ; 175 * Note: I think we just suppress everything in case #2 ; 176 * 3. do not compute rates based on fewer than 20 events. ; 177 * This would include rates like deaths per 100,000, low birth ; 178 * weight as % of live births, or ratios like maternal mortality ; 179 * per 100 live births. ; 180 * Note: for crude rates if 20 <=count<100 would use Poisson, ; 181 * for computing confidence intervals but according to Cody this does ; 182 * not apply for avgs - all confidence intervals using T-distribution ; 183 * which already adjusts for small n ; 184 * ZW-s program uses ".A" to identify cells for suppression. ; 172 * (Comments include rulse for Vital Statistics Counts and Rates( ; 173 * 1. If denominator (popcount > 300) ; 174 * 1a. If count <5 ; 175 * Suppress cells ; 176 * 1b. Suppress complimentarty cells if you can arrive at the ; 177 * number in a cell less than 5 by subtraction ; 178 * Note: I think we just suppress everything in case #1a and 1b ; 179 * 2. If count > 5 and < 20 ; 180 * Suprss rates, but compute counts ; 181 * This would include rates like deaths per 100,000, low birth ; 182 * weight as % of live births, or ratios like maternal mortality ; 183 * per 100 live births. ; 184 * if 20<=count<=100 (events between 20 and 100) ; 185 * (according to Cody this does not apply for avgs?? ; 186 * 2. If denominater (popcount < 300) ; 187 * 2a. If count > 20 ; 188 * Report count and rates with confidence intervals ; 189 * 2b. If count > 20 ; 190 * Suppress rates and counts ; 191 * ZW-s program uses ".A" to identify cells for suppression. ; 185 192 * I have co-opted his method so I can use the MT logic for cell ; 186 193 * suppression instead of the standard IBIS logic. And I need to use ; … … 215 222 216 223 * suppress if popcount <300 and count < 20 events. ; 217 if count<20 then do;224 if 1<=count<20 then do; 218 225 n=.A; 219 226 redflag=put('Suppressed', $16.); … … 226 233 end; 227 234 228 if count<=0 then do; 229 redflag=put('No Variance', $15.); *no variance, n=0; 230 n=count; *ibis-q needs a count variable named 'n'; 235 if count<0 then do; 236 redflag=put('No Variance', $15.); *no variance; 231 237 end; 232 238 … … 253 259 --------BoNdArY-------- 254 260 1 suppressed_variables 1 255 n256 --------BoNdArY-------- 261 n 262 --------BoNdArY-------- -
adopters/mt/trunk/src/main/backend_qModules/birth23/MT_Percentage_data_frame.def
r10949 r19744 1 # NM_Percentage_data_frame.def1 #MT_Percentage_data_frame.def 2 2 #Generic percentage .def file 3 3 #Uses %spvar1% in place of name of variable and the var level for percentage calculation [e.g., "bwtgp in (1 2)"] 4 4 #spvar1 is set in Module.xml file as a configuration parameter value 5 5 #MT_ version checks MT population data file for population size for cell suppression 6 #MT_ version also calculate RSE andprovides reliability_flag data6 #MT_ version provides reliability_flag data 7 7 # 8 8 f type special … … 57 57 58 58 data new; 59 *length count 8; *ZW put this in his ibisq code, so we don't need it here anymore.; 59 60 60 merge frame tmp; *must list frame dataset first, then tmp; 61 61 by %cross1% … … 89 89 * IBIS does not need the population dataset to produce a percent.; 90 90 * The following code, through the end of the macro, is used to ; 91 * compute the RSE for the data stability indicator and to check ; 92 * the numerator and denominator counts for the cell suppression. ; 91 * check numerator and denominator counts for cell suppression. ; 93 92 *****************************************************************; 94 93 %let flag=0; … … 102 101 proc summary data=poptmp; 103 102 var popcount; 104 output out=pop sum=pop num;103 output out=pop sum=popcount; 105 104 run; 106 105 proc sql; … … 117 116 output out=pop sum=popcount; 118 117 run; 119 data pop; 120 set pop; 121 rename 122 ?popcross1? %popcross1%=%cross1% 123 ?popcross2? %popcross2%=%cross2% 124 ; 125 drop _TYPE_ _FREQ_ ; 126 run; 127 proc sort data=pop; 128 ?popcross1? by %cross1%; 129 ?popcross2? by %cross2%; 130 run; 131 proc sort data=tmp; 132 ?popcross1? by %cross1%; 133 ?popcross2? by %cross2%; 134 run; 135 proc print data=pop noobs; title2 '3. POP - pop dataset'; run; 136 data rate; 137 merge tmp pop; 138 ?popcross1? by %cross1%; 139 ?popcross2? by %cross2%; 140 run; 118 proc sql; 119 create table rate as 120 select tmp.*, pop.* 121 from tmp, pop 122 where 123 ?popcross1? tmp.%cross1%=pop.%popcross1%; 124 ?popcross2? tmp.%cross2%=pop.%popcross2%; 125 quit; 141 126 %end; 142 127 … … 147 132 output out=pop sum=popcount; 148 133 run; 149 data pop; 150 set pop; 151 rename %popcross1%=%cross1% %popcross2%=%cross2% ; 152 run; 153 proc sort data=pop; 154 by %cross1% %cross2%; 155 run; 156 proc sort data=tmp; 157 by %cross1% %cross2%; 158 run; 159 data rate; 160 merge tmp pop; 161 by %cross1% %cross2% 162 ; 163 run; 134 proc sql; 135 create table rate as 136 select tmp.*, pop.* 137 from tmp, pop 138 where tmp.%cross1%=pop.%popcross1% and 139 tmp.%cross2%=pop.%popcross2%; 140 quit; 164 141 %end; 165 142 %mend; 166 143 %popcross; 167 proc print data=rate ; title2 'rate'; run;168 169 ********************** 4. tmp, again Redflag and cell suppression *************;144 proc print data=rate noobs; title2 '3. RATE - tmp merged with pop dataset'; 145 146 ********************** 4. tmp, again Redflag and cell suppression *************; 170 147 * Create the output variables for the IBIS xml/map file. ; 171 148 * Add Redflag ; 172 * (redflag is the statistical stability indicator based on the ; 173 * relative standard error (RSE, or coefficient of variation). ; 174 * Redflag values created here are converted to images or special ; 149 * Redflag is used to describe why valuses have been suppressed ; 150 * Redflag values created here may be converted to images or special ; 175 151 * characters in IBIS-View application XSLTfiles, for instance: ; 176 152 * (xslt\html\query\module\result\ResultPage.xslt, ...Values.xslt) ; 177 153 * ; 178 154 * And Apply Montana specific Small numbers rules as follows ; 179 * 1. Suppress cells if absolute count <5 ; 180 * 2. Suppress complimentarty cells if you can arrive at the ; 181 * number in a cell less than 5 by subtraction ; 182 * Note: I think we just suppress everything in case #2 ; 183 * 3. do not compute rates based on fewer than 20 events. ; 184 * This would include rates like deaths per 100,000, low birth ; 185 * weight as % of live births, or ratios like maternal mortality ; 186 * per 100 live births. ; 187 * 4. use Poisson exact computation of rates for 20 through 100 ; 188 * events and normal approximation for more than 100 events. ; 189 * 5. If RSE > .30 suppress output ; 190 * ZW-s program uses ".A" to identify cells for suppression. ; 155 * (Comments include rulse for Vital Statistics Counts and Rates( ; 156 * 1. If denominator (popcount > 300) ; 157 * 1a. If count <5 ; 158 * Suppress cells ; 159 * 1b. Suppress complimentarty cells if you can arrive at the ; 160 * number in a cell less than 5 by subtraction ; 161 * Note: I think we just suppress everything in case #1a and 1b ; 162 * 2. If count > 5 and < 20 ; 163 * Supress rates, but compute counts ; 164 * This would include rates like deaths per 100,000, low birth ; 165 * weight as % of live births, or ratios like maternal mortality ; 166 * per 100 live births. ; 167 * if 20<=count<=100 (events between 20 and 100) ; 168 * (according to Cody this does not apply for avgs?? ; 169 * 2. If denominater (popcount < 300) ; 170 * 2a. If count > 20 ; 171 * Report count and rates with confidence intervals ; 172 * 2b. If count < 20 ; 173 * Suppress rates and counts ; 174 * ZW-s program uses ".A" to identify cells for suppression. ; 191 175 * I have co-opted his method so I can use the MT logic for cell ; 192 176 * suppression instead of the standard IBIS logic. And I need to use ; … … 199 183 data tmp; 200 184 set rate; 185 n=count; *ibis-q needs a count variable named 'n'; 201 186 rate=count/totalnum; 202 187 203 if count<=0 then do; 204 rateper=0; 205 stderr=sqrt((3/totalnum)*(1-(3/totalnum))/totalnum)*100; 206 redflag=put('No Variance', $15.); *no variance, n=0, rse=div by zero; 207 n=count; *ibis-q needs a count variable named 'n'; 188 if popcount>=300 then do; 189 190 * Suppress cells if absolute count <5; 191 192 193 if count=0 and 1<totalnum<5 then do; * also need to test for count = 0, but # births (totalnum) < 5; 194 rateper=.; 195 LL=put('**', 15.0); 196 UL=put('**', 15.0); 197 redflag=put('Suppressed', $15.); 198 end; 199 else if count = 0 then do; 200 rateper=.; 201 LL=.; 202 UL=.; 203 end; 204 if 1<=count<5 then do; 205 rateper=.A; 206 LL=put('**', 15.0); 207 UL=put('**', 15.0); 208 totalnum=.A; 209 redflag=put('Suppressed', $15.); 210 n=.A; 211 end; 212 213 * do not compute rates based on fewer than 20 events, but provide counts; 214 215 if 5<=count<20 then do; 216 rateper=.A; 217 LL=put('**', 15.0); 218 UL=put('**', 15.0); 219 redflag=put('Suppressed %', $16.); 220 end; 221 222 if 20<=count<=100 then do; 223 * for events between 20 and 100, use Poisson to calculate confidence intervals; 224 225 rateper=(rate*100); 226 t1= GAMINV(.025,count)/totalnum*100; 227 if (t1<0) then t1=0; 228 LL=put(t1, 8.2); 229 UL=put(( GAMINV(.975,count)/totalnum*100),8.2); 230 end; 231 232 * and normal approximation for more than 100 events. ; 233 234 if count>100 then do; 235 rateper=(rate*100); 236 stderr=sqrt(rate*(1-rate)/totalnum)*100; 237 t1=(rateper-(1.96*stderr)); 238 if (t1<0) then t1=0; 239 LL=put(t1, 8.2); 240 UL=put((rateper+(1.96*stderr)), 8.2); 241 LL=compress(LL); 242 UL=compress(UL); 243 redflag=put('-', $15.); 244 end; 208 245 end; 209 210 * Suppress cells if absolute count <5 ; 211 212 if 1<=count<5 then do; 246 247 if popcount<300 then do; 248 249 * suppress if popcount <300 and count < 20 events ; 250 251 if count=0 then do; * also need to test for count = 0, but # births (totalnum) < 20; 252 rateper=.; 253 LL=.; 254 UL=.; 255 if 1<=totalnum<20 then totalnum=.A; 256 redflag=put('Suppressed', $15.); 257 end; 258 259 if 1<=count<20 then do; 260 rateper=.A; 261 LL=put('**', 15.0); 262 UL=put('**', 15.0); 263 totalnum=.A; 264 redflag=put('Suppressed', $15.); 265 n=.A; 266 end; 267 268 269 * report rate and n if popcount <300 and count >= 20 events. ; 270 271 if 20<=count<=100 then do; 272 * for events between 20 and 100, use Poisson to calculate confidence intervals; 273 274 rateper=(rate*100); 275 t1= GAMINV(.025,count)/totalnum*100; 276 if (t1<0) then t1=0; 277 LL=put(t1, 8.2); 278 UL=put(( GAMINV(.975,count)/totalnum*100),8.2); 279 end; 280 281 * and normal approximation for more than 100 events. ; 282 283 if count>100 then do; 284 rateper=(rate*100); 285 stderr=sqrt(rate*(1-rate)/totalnum)*100; 286 t1=(rateper-(1.96*stderr)); 287 if (t1<0) then t1=0; 288 LL=put(t1, 8.2); 289 UL=put((rateper+(1.96*stderr)), 8.2); 290 LL=compress(LL); 291 UL=compress(UL); 292 redflag=put('-', $15.); 293 end; 294 end; 295 296 if count=0 then do; 297 rateper=.; 298 LL=.; 299 UL=.; 300 totalnum=.A; 301 end; 302 303 if count<0 then do; 213 304 rateper=.A; 214 305 LL=.A; 215 306 UL=.A; 216 redflag=put('Suppressed', $15.);217 n=.A; *ibis-q needs a count variable named 'n';307 totalnum=.A; 308 redflag=put('No Variance', $15.); *no variance; 218 309 end; 219 310 220 * do not compute rates based on fewer than 20 events. ;221 222 if 5<=count<20 then do;223 rateper=.A;224 LL=.A;225 UL=.A;226 redflag=put('Suppressed Rate', $16.);227 n=count; *ibis-q needs a count variable named 'n';228 end;229 230 * for events between 20 and 100, use Poisson to calculate confidence intervals;231 232 if 20<=count<=100 then do;233 rateper=(rate*100);234 t1= GAMINV(.025,count)/totalnum*100;235 if (t1<0) then t1=0;236 LL=put(t1, 8.2);237 UL=put(( GAMINV(.975,count)/totalnum*100),8.2);238 /* RSE formula for Poisson - See http://health.utah.gov/opha/IBIShelp/DataSuppression.pdf */;239 /* RSE=1/(sqrt(count))equiv to next line as per Cody */;240 rse=sqrt(100/(totalnum*rateper)) ;241 redflag=put('-', $15.);242 if rse>.3 then do;243 redflag=put('Unstable', $15.);244 rateper=.A;245 LL=.A;246 UL=.A;247 end;248 n=count; *ibis-q needs a count variable named 'n';249 end;250 251 * and normal approximation for more than 100 events. ;252 253 if count>100 then do;254 rateper=(rate*100);255 stderr=sqrt(rate*(1-rate)/totalnum)*100;256 t1=(rateper-(1.96*stderr));257 if (t1<0) then t1=0;258 LL=put(t1, 8.2);259 UL=put((rateper+(1.96*stderr)), 8.2);260 LL=compress(LL);261 UL=compress(UL);262 rse=(stderr/rateper);263 redflag=put('-', $15.);264 if rse>.3 then do;265 redflag=put('Unstable', $15.);266 rateper=.A;267 LL=.A;268 UL=.A;269 end;270 n=count; *ibis-q needs a count variable named 'n';271 end;272 311 proc print data=tmp; title2 '4. tmp again - output variables for the IBIS xml/map and Redflag and cell suppression'; 273 312 run; 274 313 275 314 --------BoNdArY-------- 315 # definition for output file 276 316 f out_variable rateper 277 # definition for output file278 317 f xml_out_map_file XMLPercentNumerDenomLCLUCL.map 279 318 --------BoNdArY-------- 280 319 f out_detail lbl_not_used__see_xml_out_map_file 281 rateper 8.2320 rateper 15.2 282 321 n 15.0 283 322 totalnum 15.0 284 LL 8.2 285 UL 8.2 286 redflag 15.0 287 --------BoNdArY-------- 323 LL 15.2 324 UL 15.2 325 redflag 16.0 326 --------BoNdArY-------- 327 328 ****************** 5. SUPPRESSED VARIABLES *************************; 329 * ZW-s CGI program must be told how many variables it will need to ; 330 * suppress and which ones they are. NOTE: If the SAS code, above, is; 331 * commented out, these lines can be left in the .def file without ; 332 * causing any problems. They will only be used if the SAS code, ; 333 * above is active, OR if the small_num and small_pop parameters ; 334 * are active in the .CFG file, and with non-zero values. ; 335 ********************************************************************; 288 336 --------BoNdArY-------- 289 337 1 suppressed_variables 5 290 rateper291 percentvar 292 n293 LL294 UL295 --------BoNdArY-------- 338 rateper 339 totalnum 340 n 341 LL 342 UL 343 --------BoNdArY-------- -
adopters/mt/trunk/src/main/backend_qModules/birth23/MT_RateCrude1K_data_frame.def
r19478 r19744 135 135 %mend; 136 136 %popcross; 137 proc print data=rate noobs; title2 '3. RATE - tmp merged with pop dataset'; 137 proc print data=rate noobs; title2 '3. RATE - tmp merged with pop dataset'; 138 run; 138 139 139 140 ********************** 4. tmp, again Redflag and cell suppression *************; … … 146 147 * ; 147 148 * And Apply Montana specific Small numbers rules as follows ; 148 * 1. Suppress cells if absolute count <5 ; 149 * 2. Suppress complimentarty cells if you can arrive at the ; 150 * number in a cell less than 5 by subtraction ; 151 * Note: I think we just suppress everything in case #2 ; 152 * 3. do not compute rates based on fewer than 20 events. ; 153 * This would include rates like deaths per 100,000, low birth ; 154 * weight as % of live births, or ratios like maternal mortality ; 155 * per 100 live births. ; 156 * 4. use Poisson exact computation of rates for 20 through 100 ; 157 * events and normal approximation for more than 100 events. ; 158 * 5. If RSE > .30 suppress output ; 159 * ZW-s program uses ".A" to identify cells for suppression. ; 160 * I have co-opted his method so I can use the MT logic for cell ; 161 * suppression instead of the standard IBIS logic. And I need to use ; 162 * ZWs program because it will suppress the table marginals that can ; 163 * be used to calculate the suppressed cells. If this code is used, ; 164 * the .def file should have the MT_ prefix. Needs suppressed_variables ; 165 * code at the end of this file to work. ; 149 * (Comments include rulse for Vital Statistics Counts and Rates( ; 150 * 1. If denominator (popcount > 300) ; 151 * 1a. If count <5 ; 152 * Suppress cells ; 153 * 1b. Suppress complimentarty cells if you can arrive at the ; 154 * number in a cell less than 5 by subtraction ; 155 * Note: I think we just suppress everything in case #1a and 1b ; 156 * 2. If count > 5 and < 20 ; 157 * Supress rates, but compute counts ; 158 * This would include rates like deaths per 100,000, low birth ; 159 * weight as % of live births, or ratios like maternal mortality ; 160 * per 100 live births. ; 161 * if 20<=count<=100 (events between 20 and 100) ; 162 * (according to Cody this does not apply for avgs?? ; 163 * 2. If denominater (popcount < 300) ; 164 * 2a. If count > 20 ; 165 * Report count and rates with confidence intervals ; 166 * 2b. If count > 20 ; 167 * Suppress rates and counts ; 168 * ZW-s program uses ".A" to identify cells for suppression. ; 169 * ZWs program suppresses the table marginals that can be used to calculate ; 170 * the suppressed cell values ; 171 *I have turned that off in the .cfg file with the following command ; 172 * d suppress_rule skip ; 173 *I think this stops .A from working so I need to use put to put in **, etc ; 174 *We will have to see how it affects calulating suppressed cells by using ; 175 * table marginals ; 166 176 *******************************************************************************; 167 177 … … 171 181 rate=count/popcount; 172 182 173 174 183 if popcount>=300 then do; 175 176 * Suppress cells if absolute count <5 ; 184 185 if count=0 then do; 186 rateper=.A; 187 LL=.A; 188 UL=.A; 189 end; 190 * Suppress cells if absolute count <5; 177 191 178 192 if 1<=count<5 then do; 179 193 rateper=.A; 180 LL= put('**', 15.0);181 UL= put('**', 15.0);194 LL=.A; 195 UL=.A; 182 196 redflag=put('Suppressed', $15.); 183 197 n=.A; 184 198 end; 185 199 186 200 * do not compute rates based on fewer than 20 events, but provide counts; 187 201 188 202 if 5<=count<20 then do; 189 203 rateper=.A; 190 LL= put('**', 15.0);191 UL= put('**', 15.0);204 LL=.A; 205 UL=.A; 192 206 redflag=put('Suppressed Rate', $16.); 193 207 end; … … 214 228 LL=compress(LL); 215 229 UL=compress(UL); 216 rse=(stderr/rateper);217 230 redflag=put('-', $15.); 218 231 end; … … 220 233 221 234 if popcount<300 then do; 222 235 236 if count=0 and popcount <20 then do; 237 rateper=.A; 238 LL=.A; 239 UL=.A; 240 popcount=.A; 241 redflag=put('Suppressed', $15.); 242 end; 243 else if count=0 then do; 244 rateper=.A; 245 LL=.A; 246 UL=.A; 247 end; 223 248 * suppress if popcount <300 and count < 20 events. ; 224 249 225 if count<20 then do;226 rateper=.A; 227 LL= put('**', 15.0);228 UL= put('**', 15.0);250 if 1<=count<20 then do; 251 rateper=.A; 252 LL=.A; 253 UL=.A; 229 254 redflag=put('Suppressed', $15.); 230 255 n=.A; 231 256 end; 232 233 257 234 258 * report rate and n if popcount <300 and count >= 20 events. ; … … 255 279 LL=compress(LL); 256 280 UL=compress(UL); 257 rse=(stderr/rateper);258 281 redflag=put('-', $15.); 259 282 end; 260 283 end; 261 284 262 if count<=0 then do; 263 rateper=0; 264 stderr=sqrt((3/popcount)*(1-(3/popcount))/popcount)*1000; 265 266 n=count; *ibis-q needs a count variable named 'n'; 285 if count<0 then do; 267 286 rateper=.A; 268 287 LL=.A; 269 288 UL=.A; 270 redflag=put('No Variance', $15.); *no variance, n=0, rse=div by zero;289 redflag=put('No Variance', $15.); *no variance; 271 290 end; 272 291 … … 288 307 --------BoNdArY-------- 289 308 290 ****************** 7. SUPPRESSED VARIABLES *************************;309 ****************** 5. SUPPRESSED VARIABLES *************************; 291 310 * ZW-s CGI program must be told how many variables it will need to ; 292 311 * suppress and which ones they are. NOTE: If the SAS code, above, is; … … 297 316 ********************************************************************; 298 317 --------BoNdArY-------- 299 1 suppressed_variables 4 300 rateper 301 n 302 LL 303 UL 304 --------BoNdArY-------- 318 1 suppressed_variables 5 319 rateper 320 n 321 popcount 322 LL 323 UL 324 --------BoNdArY-------- -
adopters/mt/trunk/src/main/backend_qModules/birth23/MT_TotalFertRate.def
r10949 r19744 67 67 run; 68 68 69 data tmp; 70 set rate; 71 ?cross1? if (%cross1%^=.); 72 ?cross2? if (%cross2%^=.); 73 ?cross1? if (%cross1%=-99) then %cross1%=.; 74 ?cross2? if (%cross2%=-99) then %cross2%=.; 75 proc print data=tmp; title 'before final'; run; 76 69 77 ********************** 4. tmp, again Redflag and cell suppression *************; 70 78 * Create the output variables for the IBIS xml/map file. ; 71 79 * Add Redflag ; 72 80 * (redflag is the statistical stability indicator based on the ; 73 * relative standard error (RSE, or coefficient of variation). ;74 81 * Redflag values created here are converted to images or special ; 75 82 * characters in IBIS-View application XSLTfiles, for instance: ; 76 83 * (xslt\html\query\module\result\ResultPage.xslt, ...Values.xslt) ; 77 84 * ; 78 85 * And Apply Montana specific Small numbers rules as follows ; 79 * 1. Suppress cells if absolute count <5 ; 80 * 2. Suppress complimentarty cells if you can arrive at the ; 81 * number in a cell less than 5 by subtraction ; 82 * Note: I think we just suppress everything in case #2 ; 83 * 3. do not compute rates based on fewer than 20 events. ; 84 * This would include rates like deaths per 100,000, low birth ; 85 * weight as % of live births, or ratios like maternal mortality ; 86 * per 100 live births. ; 87 * 4. use Poisson exact computation of rates for 20 through 100 ; 88 * events and normal approximation for more than 100 events. ; 89 * 5. If RSE > .30 suppress output ; 90 * ZW-s program uses ".A" to identify cells for suppression. ; 86 * (Comments include rulse for Vital Statistics Counts and Rates( ; 87 * 1. If denominator (popcount > 300) ; 88 * 1a. If count <5 ; 89 * Suppress cells ; 90 * 1b. Suppress complimentarty cells if you can arrive at the ; 91 * number in a cell less than 5 by subtraction ; 92 * Note: I think we just suppress everything in case #1a and 1b ; 93 * 2. If count > 5 and < 20 ; 94 * Supress rates, but compute counts ; 95 * This would include rates like deaths per 100,000, low birth ; 96 * weight as % of live births, or ratios like maternal mortality ; 97 * per 100 live births. ; 98 * if 20<=count<=100 (events between 20 and 100) ; 99 * (according to Cody this does not apply for avgs?? ; 100 * 2. If denominater (popcount < 300) ; 101 * 2a. If count > 20 ; 102 * Report count and rates with confidence intervals ; 103 * 2b. If count > 20 ; 104 * Suppress rates and counts ; 105 * ZW-s program uses ".A" to identify cells for suppression. ; 91 106 * I have co-opted his method so I can use the MT logic for cell ; 92 107 * suppression instead of the standard IBIS logic. And I need to use ; … … 96 111 * code at the end of this file to work. ; 97 112 *******************************************************************************; 98 data tmp; 99 set rate; 100 101 if count<=0 then do; 113 114 data tmp; 115 set tmp; 116 n=count; *ibis-q needs a count variable named 'n'; 117 rate=count/popcount; 118 119 120 if popcount>=300 then do; 121 122 * Suppress cells if absolute count <5 ; 123 124 if 1<=count<5 then do; 125 rateper=.A; 126 LL=put('**', 15.0); 127 UL=put('**', 15.0); 128 redflag=put('Suppressed', $15.); 129 n=.A; 130 end; 131 132 * do not compute rates based on fewer than 20 events, but provide counts; 133 134 if 5<=count<20 then do; 135 rateper=.A; 136 LL=put('**', 15.0); 137 UL=put('**', 15.0); 138 redflag=put('Suppressed Rate', $16.); 139 end; 140 141 if 20<=count<=100 then do; 142 * for events between 20 and 100, use Poisson to calculate confidence intervals; 143 144 rateper=(rate*1000); 145 t1= GAMINV(.025,count)/popcount*1000; 146 if (t1<0) then t1=0; 147 LL=put(t1, 8.2); 148 UL=put(( GAMINV(.975,count)/popcount*1000),8.2); 149 end; 150 151 * and normal approximation for more than 100 events. ; 152 153 if count>100 then do; 154 rateper=(rate*1000); 155 stderr=sqrt(rate*(1-rate)/popcount)*1000; 156 t1=(rateper-(1.96*stderr)); 157 if (t1<0) then t1=0; 158 LL=put(t1, 8.2); 159 UL=put((rateper+(1.96*stderr)), 8.2); 160 LL=compress(LL); 161 UL=compress(UL); 162 redflag=put('-', $15.); 163 end; 164 end; 165 166 if popcount<300 then do; 167 168 * suppress if popcount <300 and count < 20 events. ; 169 170 if 1<=count<20 and popcount <20 then 171 do; 172 rateper=.A; 173 LL=put('**', 15.0); 174 UL=put('**', 15.0); 175 n=.A; 176 popcount=.A; 177 redflag=put('Suppressed', $15.); 178 end; 179 else if 1<=count<20 then 180 do; 181 rateper=.A; 182 LL=put('**', 15.0); 183 UL=put('**', 15.0); 184 n=.A; 185 popcount=.A; 186 redflag=put('Suppressed', $15.); 187 end; 188 189 * report rate and n if popcount <300 and count >= 20 events. ; 190 191 if 20<=count<=100 then do; 192 * for events between 20 and 100, use Poisson to calculate confidence intervals; 193 194 rateper=(rate*1000); 195 t1= GAMINV(.025,count)/popcount*1000; 196 if (t1<0) then t1=0; 197 LL=put(t1, 8.2); 198 UL=put(( GAMINV(.975,count)/popcount*1000),8.2); 199 end; 200 201 * and normal approximation for more than 100 events. ; 202 203 if count>100 then do; 204 rateper=(rate*1000); 205 stderr=sqrt(rate*(1-rate)/popcount)*1000; 206 t1=(rateper-(1.96*stderr)); 207 if (t1<0) then t1=0; 208 LL=put(t1, 8.2); 209 UL=put((rateper+(1.96*stderr)), 8.2); 210 LL=compress(LL); 211 UL=compress(UL); 212 redflag=put('-', $15.); 213 end; 214 end; 215 216 if count<0 then do; 102 217 rateper=0; 103 218 stderr=sqrt((3/popcount)*(1-(3/popcount))/popcount)*1000; 104 redflag=put('No Variance', $15.); *no variance, n=0, rse=div by zero;105 n=count; *ibis-q needs a count variable named 'n';106 end;107 108 * Suppress cells if absolute count <5 ;109 110 if 1<=count<5 then do;111 219 rateper=.A; 112 220 LL=.A; 113 221 UL=.A; 114 redflag=put('Suppressed', $15.); 115 n=.A; *ibis-q needs a count variable named 'n'; 222 redflag=put('No Variance', $15.); *no variance; 116 223 end; 117 224 118 * do not compute rates based on fewer than 20 events. ; 119 120 if 5<=count<20 then do; 121 rateper=.A; 122 LL=.A; 123 UL=.A; 124 redflag=put('Suppressed Rate', $16.); 125 n=count; *ibis-q needs a count variable named 'n'; 126 end; 127 128 * for events between 20 and 100, use Poisson to calculate confidence intervals; 129 130 if 20<=count<=100 then do; 131 rateper=(rate*1000); 132 t1= GAMINV(.025,count)/popcount*1000; 133 if (t1<0) then t1=0; 134 LL=put(t1, 8.2); 135 UL=put(( GAMINV(.975,count)/popcount*1000),8.2); 136 /* RSE formula for Poisson - See http://health.utah.gov/opha/IBIShelp/DataSuppression.pdf */; 137 /* RSE=1/(sqrt(count))equiv to next line as per Cody */; 138 rse=sqrt(1000/(popcount*rateper)) ; 139 redflag=put('-', $15.); 140 if rse>.3 then do; 141 redflag=put('Unstable', $15.); 142 rateper=.A; 143 LL=.A; 144 UL=.A; 145 end; 146 n=count; *ibis-q needs a count variable named 'n'; 147 end; 148 149 * and normal approximation for more than 100 events. ; 150 151 if count>100 then do; 152 rateper=(rate*1000); 153 stderr=sqrt(rate*(1-rate)/popcount)*1000; 154 t1=(rateper-(1.96*stderr)); 155 if (t1<0) then t1=0; 156 LL=put(t1, 8.2); 157 UL=put((rateper+(1.96*stderr)), 8.2); 158 LL=compress(LL); 159 UL=compress(UL); 160 rse=(stderr/rateper); 161 redflag=put('-', $15.); 162 if rse>.3 then do; 163 redflag=put('Unstable', $15.); 164 rateper=.A; 165 LL=.A; 166 UL=.A; 167 end; 168 n=count; *ibis-q needs a count variable named 'n'; 169 end; 170 171 rateper=rateper*5; 172 LL=LL*5; 173 UL=UL*5; 174 ?cross1? if (%cross1%=-99) then %cross1%=.; 175 ?cross2? if (%cross2%=-99) then %cross2%=.; 176 225 proc print data=tmp; title2 '4. tmp again - output variables for the IBIS xml/map and Redflag and cell suppression'; 177 226 run; 178 proc print; title2 'final'; run; 179 180 --------BoNdArY-------- 227 228 --------BoNdArY-------- 229 # definition for output file 181 230 f out_variable rateper 182 #################################################183 # definition for output file184 231 f xml_out_map_file XMLRateNumerDenomLCLUCL.map 185 232 --------BoNdArY-------- 186 f out_detail lbl_not_used__see_xml_out_map_file 187 rateper 15.4 188 n 15.0 189 popcount 15.0 190 LL 15.4 191 UL 15.4 192 redflag 15.0 193 --------BoNdArY-------- 233 f out_detail lbl_not_used__see_xml_out_map_file 234 rateper 15.2 235 n 15.0 236 popcount 15.0 237 LL 15.2 238 UL 15.2 239 redflag 16.0 240 --------BoNdArY-------- 241 242 ****************** 5. SUPPRESSED VARIABLES *************************; 243 * ZW-s CGI program must be told how many variables it will need to ; 244 * suppress and which ones they are. NOTE: If the SAS code, above, is; 245 * commented out, these lines can be left in the .def file without ; 246 * causing any problems. They will only be used if the SAS code, ; 247 * above is active, OR if the small_num and small_pop parameters ; 248 * are active in the .CFG file, and with non-zero values. ; 249 ********************************************************************; 194 250 --------BoNdArY-------- 195 251 1 suppressed_variables 4 196 252 rateper 197 253 n 254 popcount 198 255 LL 199 256 UL … … 201 258 202 259 260 -
adopters/mt/trunk/src/main/backend_qModules/birth23/_Birth18.cfg.linux
r19478 r19744 47 47 #r small_num 5 48 48 #r small_pop 0 49 d suppress_rule skip49 #d suppress_rule skip 50 50 ############################################################################# 51 51 #value name_sas name_html name_pop prompt type1 type2 length -
adopters/mt/trunk/src/main/backend_qModules/birth23/_Birth18.cfg.windows
r19478 r19744 46 46 #r small_num 5 47 47 #r small_pop 0 48 d suppress_rule skip48 #d suppress_rule skip 49 49 ############################################################################# 50 50 #value name_sas name_html name_pop prompt type1 type2 length
Note: See TracChangeset
for help on using the changeset viewer.