Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: problem with "byable(recall)"


From   Sophie Roidot et Pierre Gaudebout <[email protected]>
To   [email protected]
Subject   st: problem with "byable(recall)"
Date   Sat, 31 May 2003 15:01:28 +0200

--
I have some problems in the use of " byable ( recall ) ".
I am responsible for the statistical analysis of an survey of satisfaction of the patients hospitalized in several Parisian hospitals (26 hospitals with hundred of questionnaires realized by hospital with drawn lots outgoing patients).
The questionnaire includes 43 items of satisfaction.
Every item containing 5 modalities of answer (from " very satisfied " (5) to " In no way satisfied " (1)).
One of my objectives is to compare for every item the % of very satisfied persons in a hospital to that of 25 other hospitals.
I realized a program allowing the comparison from a hospital to 25 others and I would like I could make this program run with the option " by " hospital " ". I know that I have to use " byable ( recall ) but my attempts failed.
Somebody could put me on the way.
( At the moment the only solution which I found to by-pass this problem is to use one " forvalues k = 1 ( 1 ) 26 {" myprog " `k '})
My program is the following one:

capture log close
log using boucles3, replace
set more off

# delimit ;
*program drop test_item;

program define test_item/*, rclass sortpreserve byable(recall)*/;
version 7.0 ;
use "SAPHORA_2003:SAPHORA_2003nwb", clear ;
preserve ;

tempfile wks ;
save "`wks'" ;
use "`wks'", clear ;
local i = v3b ;
keep v1 v3 v3b v18 v19 v23 v24 v20 v25 v21 w22 w37 v35 w27 w32 v38 /*w39*/ v29 w30 w26 new_coef`i' ;

local h : label h�plbl `i' ;
di as text _col(10) "H�pital " "`h'" _col(45) "Ensemble des h�pitaux sauf " "`h'" ;
di as text _dup(110) "-" ;
di as text "item" _col(10) "+" _col(20) "-" _col(30) "total "
_col(45) "+" _col(55) "-" _col(65) "total "
_col(80) %5.2f " chi2 " _col(90) %5.2f " p " ;

di as text _dup(110) "-" ;

foreach var of varlist v18 v19 v23 v24 v20 v25 v21 w22 w37 v35 w27 w32 v38 /*w39*/ v29 w30 w26 { /*BOUCLE POUR CHAQUE ITEM*/


tempvar item;
quietly gen `item' = new_coef`i' if `var' == 5;
quietly recode `item' . = 0 if `var' ~= 5 & `var' ~= . ;



local j = 26 ;
local npc = 0 ;
local wpc = 0 ;

quietly summarize `item' if v3b == `i' ;
if r(N) == 0 {
local n`i' = r(N) ;
local m`i' = r(N)
};
else if r(N) ~= 0 {
local n`i' = r(N) * r(mean) ;
local m`i' = r(N) * (1 - r(mean))
};


while `j' > 0 { /*BOUCLE INTERNE POUR CALCUL POND�R� DU % DE */
if `j' ~= `i' { /*TR�S SATISFAITS POUR LES AUTRES H�PITAUX */
quietly summarize `item' if v3b == `j';
local n`j' = r(N) ;
if r(N) == 0 {
local p`j' = 0
};
else if r(N) ~= 0 {
local p`j' = r(mean)
};
local npc = `npc' + `n`j'' ;
local wpc = `p`j'' + `wpc' ;
};
else {
local j = `j'
};
local j = `j'- 1
};


local b = `npc' * `wpc' ;
local d = `npc' * (1 - `wpc') ;
local A = round(`n`i'',1);
local C = round(`m`i'',1);
local B = round(`b',1);
local D = round(`d',1);

/*TEST DE COMPARAISON DE L'H�P. i */
if `A' ~= 0 & `C' ~= 0 & `B' ~= 0 & `D' ~= 0 {
quietly tabi `A' `B' \ `C' `D' , all exact col ;

di "`var'" _col(10) %5.1f 100 * `A'/(`A'+`C')
_col(20) %5.1f 100 * `C'/(`A'+`C')
_col(30) `A'+`C'
_col(45) %5.1f 100 * `B'/(`B'+`D')
_col(55) %5.1f 100 * `D'/(`B'+`D')
_col(65) `B'+`D'
_col(80) %5.2f r(chi2) _col(90) %5.2f r(p) as result ;
di as text _dup(110) "-"
};
else if (`A' == 0 | `C' == 0 | `B' == 0 | `D' == 0)
& ( `A'+`C' ~= 0 ) {
di "`var'" _col(10) %5.1f 100 * `A'/(`A'+`C')
_col(20) %5.1f 100 * `C'/(`A'+`C')
_col(30) `A'+`C'
_col(45) %5.1f 100 * `B'/(`B'+`D')
_col(55) %5.1f 100 * `D'/(`B'+`D')
_col(65) `B'+`D'
_col(80) " non �valuable ";
di as text _dup(110) "-" ;
else if ( `A'+`C' == 0 ) {
di "`var'" _col(10) %5.1f " "
_col(20) %5.1f " "
_col(30) " 0 "
_col(45) %5.1f 100 * `B'/(`B'+`D')
_col(55) %5.1f 100 * `D'/(`B'+`D')
_col(65) `B'+`D'
_col(80) " non �valuable ";
di as text _dup(110) "-" ;
}
};
end;

log close ;
exit ;





Thanks to all

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index