How do I create a table as shown below (Table A) using proc tabulate or proc report. I would like to show only the numbers in "Went to School?=Yes" column in the "Completed High School?" column. That means only the "yes" to the :"Went to School?" column will be shown in "Completed High School?" column. I tried a lot but failed.
(Dataset and codes are mentioned after Table B)
Table A
gender
went_to_sch
completed_hi_sch
F
M
no
yes
no
yes
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
city
4
40
6
60
.
.
2
20
8
80
2
25
6
75
A
B
4
40
6
60
2
20
2
20
6
60
1
17
5
83
C
6
60
4
40
2
20
.
.
8
80
3
38
5
63
When I run my code (see below) it produces a table like Table B.
Table B
gender
went_to_sch
completed_hi_sch
F
M
no
yes
no
yes
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
N
RowPctN
city
4
40
6
60
.
.
2
20
8
80
2
20
2
20
6
60
A
B
4
40
6
60
2
20
2
20
6
60
4
40
1
10
5
50
C
6
60
4
40
2
20
.
.
8
80
2
20
3
30
5
50
Dataset:
Proc sql; create table have (id char, city char, gender char, went_to_sch char, completed_hi_sch char); insert into have values ("1", "A", "M", "yes", "yes") values ("2", "B", "M", "no", " " ) values ("3", "C", "M", "yes", "no") values ("4", "A", "F", "yes", "yes") values ("5", "C", "F", "yes", "yes") values ("6", "C", "F", " ", " ") values ("7", "A", "M", "yes", "yes") values ("8", "B", "M", "yes", "no") values ("9", "B", "M", "yes", "yes") values ("10", "A", "F", "no", " " ) values ("11", "B", "F", "yes", "yes") values ("12", "C", "F", "yes", "yes") values ("13", "A", "M", "yes", "no") values ("14", "B", "F", "yes", "yes") values ("15", "C", "M", " ", " ") values ("16", "A", "M", "yes", "yes") values ("17", "B", "M", "no", " ") values ("18", "C", "M", "yes", "no") values ("19", "A", "F", "yes", "yes") values ("20", "C", "F", "yes", "yes") values ("21", "B", "F", " ", " ") values ("22", "A", "M", "yes", "yes") values ("23", "C", "M", "yes", "no") values ("24", "B", "M", "yes", "yes") values ("25", "A", "F", "no", " " ) values ("26", "C", "F", "yes", "yes") values ("27", "C", "F", "yes", "yes") values ("28", "A", "M", "yes", "no") values ("29", "B", "F", "yes", "yes") values ("30", "B", "M", " ", " "); select * from have; quit;
SAS code:
proc tabulate data = have; class City Gender Went_to_Sch Completed_Hi_Sch/ missing; tables City, ( Gender Went_to_Sch Completed_Hi_Sch) *(N ROWPCTN); run;
... View more