「FREQプロシジャ2」の編集履歴(バックアップ)一覧はこちら
「FREQプロシジャ2」(2008/10/12 (日) 23:56:58) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
&setpagename(FREQプロシジャ)
&font(#6633ff,18px){''<文字データの集計>''}
【例題】ある治験での喫煙者の有無を性別ごとに集計する
#highlight(sas){
/*テストデータ*/
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;}
#highlight(sas){
/*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;}
#image(http://www39.atwiki.jp/sas_help/?cmd=upload&act=open&page=%E5%8F%82%E7%85%A7%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E4%B8%80%E8%A6%A7&file=freq1.JPG)
#highlight(sas){
/*2次元のクロス集計*/
proc freq data = test ;
tables sex * smoke / out = out2;
format sex f_sex. smoke noyes.;
run;}
#image(http://www39.atwiki.jp/sas_help/?cmd=upload&act=open&page=%E5%8F%82%E7%85%A7%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E4%B8%80%E8%A6%A7&file=freq2.JPG)
#highlight(sas){
/*薬剤別、性別と喫煙者の有無のクロス集計*/
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;}
#image(http://www39.atwiki.jp/sas_help/?cmd=upload&act=open&page=%E5%8F%82%E7%85%A7%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E4%B8%80%E8%A6%A7&file=freq3.JPG)
&font(i,b){[[+ FREQプロシジャへのリンク +>FREQプロシジャ]]}
#hr(height=1,color=#002bb8)
&setpagename(FREQプロシジャ)
&font(#6633ff,18px){''<文字データの集計>''}
【例題】ある治験での喫煙者の有無を性別ごとに集計する
#highlight(sas){
/*テストデータ*/
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;}
#highlight(sas){
/*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;}
#image(http://www39.atwiki.jp/sas_help?cmd=upload&act=open&pageid=19&file=freq1.JPG)
#highlight(sas){
/*2次元のクロス集計*/
proc freq data = test ;
tables sex * smoke / out = out2;
format sex f_sex. smoke noyes.;
run;}
#image(http://www39.atwiki.jp/sas_help?cmd=upload&act=open&pageid=19&file=freq2.JPG)
#highlight(sas){
/*薬剤別、性別と喫煙者の有無のクロス集計*/
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;}
#image(http://www39.atwiki.jp/sas_help?cmd=upload&act=open&pageid=19&file=freq3.JPG)
&font(i,b){[[+ FREQプロシジャへのリンク +>FREQプロシジャ]]}
#hr(height=1,color=#002bb8)