Help using Base SAS procedures

Proc Tabulate and Missing Names

Not applicable
Posts: 0

Proc Tabulate and Missing Names

Why isn't this working to show the missing class observations for a class variable?
Everything did run when 'missing ' was omitted. However, I want proc tabulate to calculate var values where the distname is missing too.

proc tabulate data=kasch_update noseps out=&count missing;
class cocode coname type distname schcode schname;
var total cond uncond pme pbe;

Posts: 9,372

Re: Proc Tabulate and Missing Names

Posted in reply to deleted_user
There are several different kinds of missing conditions and ways to surface zero values and/or headers for class variables with missing data.

1) you have an observation that contains a missing value for a class variable. Normally, TABULATE excludes that observation from the table. In this case, you can use the MISSING option in the PROC TABULATE statement, or in the CLASS statement to reveal the observation. Your data might look like this for the MISSING option to have an effect:
Region val
AAA 11
AAA 10
BBB 10
BBB 12
CCC 10

In order to see an "empty" header under Region with 15 for value, you really need the MISSING option (either on the CLASS statement or the TABULATE statement)

2) But, what if you do NOT have an observation for a particular combination of CLASS variables? Sometimes, when you use PROC TABULATE, you won't have the same number of CLASS variables on a TABULATE page or in a row or column crossing. Imagine this data situation. Note how Region AAA has Subreg values of One and Two, but Region BBB only has Subreg of One and Region CCC only has Subreg of Two:

Region Subreg val
AAA One 11
AAA Two 10
BBB One 10
BBB One 12
CCC Two 10

The MISSING option won't help you with this data condition because there just aren't any CCC observations with a Subreg of One, for example. So for this kind of data, you need to move into using the PRINTMISS option on the TABLE statement. Whether or not you also use the MISSING option depends on the data and whether there are any missing CLASS variables in your observations.

3) Another possible situation is that...let's say for some reason you have a newly introduced Region of DDD. Right now, there's no data at all for that Region, but gradually, over time, there will be data for Region = DDD. However, until there is data, you want a row or column to appear in the TABULATE output for DDD -- even though all the values might be missing (or zero). What you have to do for this data condition is tell PROC TABULATE that there is a list of values on which to base the "buckets" that it builds for CLASS variables. With a user-defined format, you can specify the Regions that you want to have appear. Then, with the PRELOADFMT option on the CLASS statement for the Region variable, then Proc TABULATE knows which values to "pre-load" in order to build the table.

(There is actually another way to accomplish what you can do with PRELOADFMT using the CLASSDATA option, but that's another discussion.)

In order to figure out what's going on with your TABULATE output, you need to figure out what your data condition is for DISTNAME in order to use the right option or set of options.

Not applicable
Posts: 0

Re: Proc Tabulate and Missing Names

Posted in reply to deleted_user
Thanks very much Cynthia!! It works now!
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation