FREQプロシジャ
<文字データの集計>
【例題】ある治験での喫煙者の有無を性別ごとに集計する
/*テストデータ*/
proc format ;
value f_sex 1 = "男"
2 = "女";
value noyes 0 = "NO"
1 = "YES";
run;
data test;
length sex 8. drug $10 smoke dose 8.;
do i = 1 to 112 ; drug = "medicine" ; sex = 1 ; smoke = 0 ; dose = 2 ; output; end;
do i = 1 to 137 ; drug = "medicine" ; sex = 1 ; smoke = 1 ; dose = 2 ; output; end;
do i = 1 to 83 ; drug = "medicine" ; sex = 2 ; smoke = 0 ; dose = 2 ; output; end;
do i = 1 to 141 ; drug = "medicine" ; sex = 2 ; smoke = 1 ; dose = 2 ; output; end;
do i = 1 to 90 ; drug = "plasebo" ; sex = 1 ; smoke = 0 ; dose = 2 ; output; end;
do i = 1 to 75 ; drug = "plasebo" ; sex = 1 ; smoke = 1 ; dose = 2 ; output; end;
do i = 1 to 86 ; drug = "plasebo" ; sex = 2 ; smoke = 0 ; dose = 2 ; output; end;
do i = 1 to 64 ; drug = "plasebo" ; sex = 2 ; smoke = 1 ; dose = 2 ; output; end;
run;
/*1次元の度数集計*/
proc freq data = test ;
tables sex smoke / out = out1; /*喫煙者の有無の集計結果のみ出力*/
format sex f_sex. smoke noyes.;
run;
proc freq data = test ;
tables sex / out = out1_1; /*性別の集計結果*/
tables smoke / out = out1_2; /*喫煙者の有無の集計結果*/
format sex f_sex. smoke noyes.;
run;
/*2次元のクロス集計*/
proc freq data = test ;
tables sex * smoke / out = out2;
format sex f_sex. smoke noyes.;
run;
/*薬剤別、性別と喫煙者の有無のクロス集計*/
proc freq data = test ;
tables sex * smoke / out = out3;
by drug ;
format sex f_sex. smoke noyes.;
run;
proc freq data = test ;
tables drug * sex * smoke / out = out4;
format sex f_sex. smoke noyes.;
run;
/*性別と喫煙者の有無別の投与量の集計*/
proc freq data = test ;
tables drug * sex * smoke / out = out5;
weight dose ;
format sex f_sex. smoke noyes.;
run;
最終更新:2008年10月12日 23:56