y***e 发帖数: 6 | 1 I have this following dataset,
ID A B C
1 1 0 1
2 0 1 0
3 . 1 0
4 0 1 .
5 . . 0
I want to make a table that count the number of 1s and 0s in A, B, and C.
Looks like this,
A B C
1 1 3 1
0 2 1 3
I know I should use proc freq with the "list" option. But the SAS returns to
me the same format with or without the list option....
Please help! Thanks a lot! |
k*******a 发帖数: 772 | 2 data a;
input ID A B C;
datalines;
1 1 0 1
2 0 1 0
3 . 1 0
4 0 1 .
5 . . 0
;
run;
proc transpose data=a out=b;
by id;
var a b c;
run;
proc freq data=b;
table col1*_name_;
run; |
d******9 发帖数: 404 | 3 We can also use data step to do it, without transpose:
Data B (drop=ID A B C);
Set A End=EOF;
If A=1 then A_1 +1;
Else if A=0 then A_0 +1;
If B=1 then B_1 +1;
Else if B=0 then B_0 +1;
If C=1 then C_1 +1;
Else if C=0 then C_0 +1;
If EOF=1 then output;
Run; |
G**7 发帖数: 391 | 4 According to Ron Cody, you can use "proc tabulate' to count missing and
nonmissing values for both character and numeric variables. |