Date: Fri, 12 Jul 1996 12:23:12 PDT
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
Subject: Re: Forcing SAS to output all categories of a variable, even
Oh, how silly of me! I answered the wrong question again. The actual
question is MUCH harder than the one I answered.
If the category '2' does not appear in the data, SAS does not notice
that 1, 3 and 4 all appeared and insert a 2. Even worse, when the
subsetting happened to exclude all category 4 observations, SAS does not
notice that the categories include 1, 2 and 3 but not 4 and add 4, while
not adding 5 which is not a valid category at all.
I suppose in the case of a subsetting WHERE, SAS could read the excluded
observations to look for excluded categories, but it does not. If you
use intermediate datasets and subsetting IF's, there is no way for SAS
If you REALLY want the omitted lines inserted, you will have to tell SAS
what lines to insert:
DO CAT=1 TO 4;
PROC FREQ DATA=MYDATA.ALLMINE;
WHERE CAT GT 2;
TABLE CAT / NOPRINT OUT=WORK.DATA;
PROC PRINT DATA=REPORT;
The FILLIN dataset has all values of CAT, with obs reflecting a count of
zero and a percent of zero for each category. The PROC FREQ generates
an output dataset with non-missing values of COUNT and PERCENT for each
value of CAT which satisfied the WHERE clause (or whatever subsetting
you choose). The merge reads the FILLIN obs, with COUNT and PERCENT of
zero, then overwrites them with the actual counts from the PROC FREQ
output dataset. Where PROC FREQ did not generate an ob because the
category did not exist, the values from FILLIN are retained in the final
See why I answered the easy question, instead?
Tim Berryhill - Contract Programmer and General Wizard
Frequently at Pacific Gas & Electric Co., San Francisco
The correlation coefficient between their views and
my postings is slightly less than 0
----------------------[Reply - Original Message]----------------------
Sent by:"Theisen, Anne C." <email@example.com>
Thanks for the suggestion. I tried it. This give me the percentage of
"missing" data for the variable but won't show that a category is
missing. For example, if RACE is suppose to have categories 1,2,3,4...
and noone responded 2, (and there is missing data) this is what I get..
. 10 10%
1 25 25%
3 25 25%
4 40 40%
but category 2 is not shown as a 0 response at 0%. What do you suggest?
Is it possible to show the "2" response option?