Help using Base SAS procedures

How do I output headers for categories with missing data?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

How do I output headers for categories with missing data?

I'm trying to use PROC TABULATE to calculate counts and amounts for a set of months for a set of data.  Some commands may not appear in all months.  The problem is that SAS EG 5.1 by default does not print out headers for missing data and I need all the Commands printed out that occurred in that year, regardless of whether they occurred in that month.   I tried to use the PRINTMISS command after the TABLE statement, to no avail.


PROC TABULATE

   DATA = BENDATA;

       VAR AMOUNT;

   CLASS MONTH / ORDER= UNFORMATTED MISSING;

   CLASS COMMAND / ORDER = UNFORMATTED MISSING;

     TABLE MONTH * COMMAND,

                  AMOUNT * N PRINTMISS ;

;

RUN;

QUIT;

I get an error that says:  "That type of name (PRINTMISS) is unknown."

What is the workaround for this in SAS EG 5.1?

Thanks,
Ben


Accepted Solutions
Solution
‎06-16-2015 11:44 AM
Super User
Posts: 11,343

Re: How do I output headers for categories with missing data?

Posted in reply to Benbo123321

The PRINTMISS error is occurring because you are missing a / to indicate non- page/row/column options.

One way IF you know there is a limited and not constantly changing list of commands is to create a custom format that is not very exciting:

proc format;

     value $command   /* assuming it is character*/

"Command1" = "Command1"

"Command2" = "Command2"

<continue>

;

run;

Then in proc tabulate add PRELOADFMT to the options for the command variable and

format command $command. ; to use the Command format.

View solution in original post


All Replies
Valued Guide
Posts: 860

Re: How do I output headers for categories with missing data?

Posted in reply to Benbo123321

I would add a dummy id before this step, populate 'A' or 1 for each variable.  Then after this step you can run another step that deletes your dummy id.:

Occasional Contributor
Posts: 13

Re: How do I output headers for categories with missing data?

Posted in reply to Steelers_In_DC

how would i go about doing that?  The code above is system generated using the UI.

Valued Guide
Posts: 860

Re: How do I output headers for categories with missing data?

Posted in reply to Benbo123321

how many columns does BENDATA have?  If you provide a list of the columns and if they are character or numeric I'll show you the code.

Occasional Contributor
Posts: 13

Re: How do I output headers for categories with missing data?

Posted in reply to Steelers_In_DC

It has 3: Month, Command, and Amount. The first two are character, the last, numeric (?).  It is the summary count.

Ben

Occasional Contributor
Posts: 13

Re: How do I output headers for categories with missing data?

Posted in reply to Benbo123321

To be clear; BENDATA has many columns.  The only ones I care about are the two above and the summary count on the AMOUNT variable.

Solution
‎06-16-2015 11:44 AM
Super User
Posts: 11,343

Re: How do I output headers for categories with missing data?

Posted in reply to Benbo123321

The PRINTMISS error is occurring because you are missing a / to indicate non- page/row/column options.

One way IF you know there is a limited and not constantly changing list of commands is to create a custom format that is not very exciting:

proc format;

     value $command   /* assuming it is character*/

"Command1" = "Command1"

"Command2" = "Command2"

<continue>

;

run;

Then in proc tabulate add PRELOADFMT to the options for the command variable and

format command $command. ; to use the Command format.

Occasional Contributor
Posts: 13

Re: How do I output headers for categories with missing data?

thank you so much.  you solved my problem. 

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 276 views
  • 1 like
  • 3 in conversation