BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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;


Thanks!
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi,
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:
[pre]
Region val
AAA 11
AAA 10
15
BBB 10
BBB 12
CCC 10
[/pre]

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:

[pre]
Region Subreg val
AAA One 11
AAA Two 10
BBB One 10
BBB One 12
CCC Two 10
[/pre]

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.

cynthia
deleted_user
Not applicable
Thanks very much Cynthia!! It works now!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 711 views
  • 0 likes
  • 2 in conversation