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
|
data test;
format region $15.;
input id region test1 $ test2 $ test3 $;
cards;
1 bourgogne oui oui oui
1 bourgogne oui oui oui
1 bourgogne oui oui oui
1 bourgogne oui oui oui
1 alsace oui non non
1 idf oui oui non
1 bourgogne oui oui oui
1 alsace oui non non
1 idf oui oui non
1 centre oui non non
1 centre oui oui non
;run;
proc sort data=test;by region;run;
data test11 (drop=i);
set test ;
array s(*) test:;
tot=0;
tot1=0;
do i =1 to dim (s);
if s(i)="oui" then tot=tot+1;
if s(i)="non" then tot1=tot1+1;
end;
by region;
retain totreoui totrenon;
if first.region then totreoui=0;
totreoui=totreoui+tot;
if first.region then totrenon=0;
totrenon=totrenon+tot1;
retain t1o 0 t1n 0 t2o 0 t2n 0 t3o 0 t3n 0;
if first.region then t1o=0;
if test1="oui" then
t1o=t1o+1;
if first.region then t1n=0;
if test1="non" then
t1n=t1n+1;
if first.region then t2o=0;
if test2="oui" then
t2o=t2o+1;
if first.region then t2n=0;
if test2="non" then
t2n=t2n+1;
if first.region then t3o=0;
if test3="oui" then
t3o=t3o+1;
if first.region then t3n=0;
if test3="non" then
t3n=t3n+1;
if last.region then output;
run;
proc sql;
create table test111 as select sum(totreoui) as total , sum(totrenon) as total1,test11.*
from test11;
quit;
proc sort data=test111; by region;run;
ods pdf file='c:\sas\test.pdf' style=styles.printer;
proc report data=test111 nowd spanrows
Style(report)={font_size=0.5 background=white just=center
frame=void rules=none cellpadding=1pt cellspacing=0.0pt borderwidth=0.1pt};
by region;
column region t1o t1n t2o t2n t3o t3n totreoui totrenon total total1;
define region / group;
define t1o / "test1 oui";
define t1n /"test1 non";
define t2o / "test2 oui";
define t2n / "test2 non";
define t3o / "test3 oui";
define t3n / "test3 non";
define totreoui /"oui region";
define totrenon /"non region";
define total /"oui national";
define total1 /"non national";
run;
ods pdf close; |
Partager