Procedure feature: |
|
Table: |
SURVEY
|
This example uses a SAS macro to create columns. The SAS macro is not
explained here. See
SAS Macro Language: Reference for information on SAS macros.
|
data survey;
input id $ diet $ exer $ hours xwk educ;
datalines;
1001 yes yes 1 3 1
1002 no yes 1 4 2
1003 no no . . .n
1004 yes yes 2 3 .x
1005 no yes 2 3 .x
1006 yes yes 2 4 .x
1007 no yes .5 3 .
1008 no no . . .
; |
|
options nodate pageno=1 linesize=80 pagesize=60; |
|
%macro countm(col);
count(&col) "Valid Responses for &col", |
|
nmiss(&col) "Missing or NOT VALID Responses for &col", |
|
count(case
when &col=.n then "count me"
end) "Coded as NO ANSWER for &col",
count(case
when &col=.x then "count me"
end) "Coded as NOT VALID answers for &col",
count(case
when &col=. then "count me"
end) "Data Entry Errors for &col"
%mend; |
|
proc sql;
title 'Counts for Each Type of Missing Response';
select count(*) "Total No. of Rows",
%countm(educ)
from survey; |
Counts for Each Type of Missing Response 1
Missing Coded as
or NOT Coded as NOT Data
Total Valid VALID NO VALID Entry
No. of Responses Responses ANSWER answers Errors
Rows for educ for educ for educ for educ for educ
------------------------------------------------------------
8 2 6 1 3 2
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.