1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| data toto0;
set ph.variable_graphique_ppi;
if bzd_ind eq . then bzd_ind=0;
run;
/* Comptage de l'effectif pour chaque modalité (sexe, âge) */
proc sql;
create table titi1 as
select
count(*) as nb,
ben_sex_cod,
age_cl
from toto0
group by
ben_sex_cod,
age_cl
;
quit;
/* Comptage de l'effectif pour chaque modalité (sexe, âge) pour bzd_ind = 1 */
proc sql;
create table titi2 as
select
count(*) as nb,
age_cl,
ben_sex_cod
from toto0
where bzd_ind eq 1
group by
ben_sex_cod,
age_cl
;
quit;
/* Calcul des % = (2) / (1) */
proc sql;
create table titi3 as
select
t1.ben_sex_cod,
t1.age_cl,
case when coalesce(t1.nb,0) ne 0 then 100*t2.nb/t1.nb else 0 end as p
from titi1 t1 left outer join titi2 t2 on t1.ben_sex_cod=t2.ben_sex_cod and t1.age_cl=t2.age_cl
;
quit;
/* On recommence sans le sexe pour avoir le calcul sur hommes + femmes */
/* Comptage de l'effectif pour chaque modalité (âge) */
proc sql;
create table titi1_ as
select
count(*) as nb,
age_cl
from toto0
group by
age_cl
;
quit;
/* Comptage de l'effectif pour chaque modalité (âge) pour bzd_ind = 1 */
proc sql;
create table titi2_ as
select
count(*) as nb,
age_cl
from toto0
where bzd_ind eq 1
group by
age_cl
;
quit;
/* Calcul des % = (2) / (1) */
proc sql;
create table titi3_ as
select
3 as ben_sex_cod, /* code sexe fictif pour total hommes + femmes */
t1.age_cl,
case when coalesce(t1.nb,0) ne 0 then 100*t2.nb/t1.nb else 0 end as p
from titi1_ t1 left outer join titi2_ t2 on t1.age_cl=t2.age_cl
;
quit;
data finale;
set titi3 titi3_;
run;
proc sgplot data= finale;
vbar age_cl/response=p group=ben_sex_cod stat=sum groupdisplay=cluster;
run; |
Partager