これは、 SO に関する以前の投稿のフォローアップです。
人種、性別、民族性を含む人口統計の頻度表を作成しようとしています。1 つの表は、調査のヒスパニック系参加者の性別による人種のクロス集計です。ただし、これまでのところヒスパニック系の参加者はいません。したがって、テーブルはすべてゼロになりますが、それでも報告する必要があります。
これはRで実行できますが、これまでのところ、SAS の解決策は見つかりませんでした。サンプルデータは以下です。
data race;
input race eth sex ;
cards;
1 2 1
1 2 1
1 2 2
2 2 1
2 2 2
2 2 1
3 2 2
3 2 2
3 2 1
4 2 2
4 2 1
4 2 2
run;
data class;
do race = 1,2,3,4,5,6,7;
do eth = 1,2,3;
do sex = 1,2;
output;
end;
end;
end;
run;
proc format;
value frace 1 = "American Indian / AK Native"
2 = "Asian"
3 = "Black or African American"
4 = "Native Hawiian or Other PI"
5 = "White"
6 = "More than one race"
7 = "Unknown or not reported" ;
value feth 1 = "Hispanic or Latino"
2 = "Not Hispanic or Latino"
3 = "Unknown or Not reported" ;
value fsex 1 = "Male"
2 = "Female" ;
run;
***** ethnicity by sex ;
proc tabulate data = race missing classdata=class ;
class race eth sex ;
table eth, sex / misstext = '0' printmiss;
format race frace. eth feth. sex fsex. ;
run;
***** race by sex ;
proc tabulate data = race missing classdata=class ;
class race eth sex ;
table race, sex / misstext = '0' printmiss;
format race frace. eth feth. sex fsex. ;
run;
***** race by sex, for Hispanic only ;
***** log indicates that a logical page with only missing values has been deleted ;
***** Thanks SAS, you're a big help... ;
proc tabulate data = race missing classdata=class ;
where eth = 1 ;
class race eth sex ;
table race, sex / misstext = '0' printmiss;
format race frace. eth feth. sex fsex. ;
run;
どこが1に等しいかを選択しているため、コードが実際に機能しないことを理解していますeth
(条件を満たすケースはありません...)。実行するコマンドを指定してもby eth
機能しません。
どんな指導も大歓迎です...