Murray
Murray

Reputation: 719

Apply format to null string

I'd like to apply a label to nulls in a character variable.

I can do this quite fine with numeric variables, but am unsuccessful with character vars. I'd like to apply the label 'Both Groups' to the null Group value (as created by the class option in proc means).

data group1;                      
   input group $1. freq;  
   datalines;
A 5
B 8
  13
;
proc format;
    value $ grpfmt  'A' = 'Group A'
                    'B' = 'Group B'
                    ''  = 'Both Groups'
                    ;
run;
proc sql;
    create table group2 as
        select group format = $grpfmt.,freq
            from group1;
quit;

Many thanks for any help.

Upvotes: 2

Views: 1106

Answers (2)

Laurent de Walick
Laurent de Walick

Reputation: 2174

Add space to the value of Both Groups, like

' ' = 'Both Groups'

Another way is to use the other option in the proc format.

other = 'Both Groups'

Upvotes: 2

dklt
dklt

Reputation: 1700

Just a wild guess...

did you try NULL = 'Both Groups' ?

Upvotes: -1

Related Questions