Help using Base SAS procedures

Putting character variables into a Proc report numeric column

Reply
User
Posts: 1

Putting character variables into a Proc report numeric column

Good afternoon all.

 

I believe I have done this in the past but can't remember how.

 

In a proc report, can I place an N/A in a cell if the value isn't possible,

 

For example I have a report like this:

                     Brown       White     Green

Dog               3               2            0

Turtle            2                0            2 

 

Since there is no such thing as a Green Dog or a White Turtle, I want to put the term 'N/A' into those cells, like so:

                     Brown       White     Green

Dog               3               2            N/A

Turtle            2                N/A        2 

 

Is this possible?

 

Thanks.

 

- Hillel

                  

 

 

PROC Star
Posts: 294

Re: Putting character variables into a Proc report numeric column

You can use a user-defined format:

 

proc format;
value myFmt
0 = 'N/A'
OTHER=[8.]; <-- Or whatever format you want.
run;

Then just use this format for the variable you're displaying.

 

If it's missing and not zero, set missing to 'N/A' in the format.

Super User
Posts: 18,577

Re: Putting character variables into a Proc report numeric column

Have you considered a custom format where . is set to NA.  I personally wouldn't use 0, because you could 0 red dogs but it's possible they exist (Clifford the Big Red Dog probably doesn't count though).

proc format;
value miss_na_fmt
. = 'N/A'
other = [best12.];
run;;

 

Ask a Question
Discussion stats
  • 2 replies
  • 111 views
  • 0 likes
  • 3 in conversation