Help using Base SAS procedures

Removing row headers in tabulate

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 129
Accepted Solution

Removing row headers in tabulate

(Related to - but not the same as my other question on headers).

I have

data test;

input v1 v2 v3;

cards;

1 1 1

2 2 4

3 4 10

;

proc tabulate;

  class v1 v2;

  var v3;

  label v1='';  /* two single quotes */

  label v3='';

  table min*v3*v1,v2;

  run;

The output I get is in the attached screenshot. In short, I get single quotes appearing for the labels for v1 and v2. How do I remove them altogether? I'm using 9.4. (If use ' ' (a space between the quotes) the variable names appear instead. I get the same result if I use double quotes).


Capture.PNG

Accepted Solutions
Solution
‎10-10-2014 08:02 AM
Super User
Posts: 10,023

Re: Removing row headers in tabulate

Posted in reply to BruceBrad
data test;
input v1 v2 v3;
cards; 
1 1 1
2 2 4
3 4 10
; 
proc tabulate; 
  class v1 v2;
  var v3;
  table min*v3=' '*v1=' ',v2;
  run;

Xia Keshan

View solution in original post


All Replies
Respected Advisor
Posts: 4,173

Re: Removing row headers in tabulate

Posted in reply to BruceBrad

Have a blank between the quotes.

Frequent Contributor
Posts: 129

Re: Removing row headers in tabulate

Tried that. If I do that, I get the variable name appearing.

Super User
Super User
Posts: 7,942

Re: Removing row headers in tabulate

Posted in reply to BruceBrad

Well, funnily enough this seems to work:

data test;

input v1 v2 v3;

cards;

1 1 1

2 2 4

3 4 10

;

run;

ods escapechar "^";

proc tabulate;

  class v1 v2;

  var v3;

  label v1="^{subscript }";  /* two single quotes */

  label v3="^{superscript }";

  table min*v3*v1,v2;

run;

Not ideal I know (I personally don't use tabulate).  You could also just output to a dataset:

proc tabulate out=xyz;

...

Then use proc report to generate the output required.

Respected Advisor
Posts: 3,799

Re: Removing row headers in tabulate

Posted in reply to BruceBrad

I would use the nob-breaking space byte(160)  'a0'x  It may be output destination dependent but it seems that something with space in the name should print as "blank".


data test;
input v1 v2 v3;
cards;
1 1 1
2 2 4
3 4 10
;
proc tabulate;
 
class v1 v2;
  var v3;
  label v1='a0'x
 
label v3='a0'x;
 
table min*v3*v1,v2;
  run;
10-10-2014 6-16-48 AM.png
Solution
‎10-10-2014 08:02 AM
Super User
Posts: 10,023

Re: Removing row headers in tabulate

Posted in reply to BruceBrad
data test;
input v1 v2 v3;
cards; 
1 1 1
2 2 4
3 4 10
; 
proc tabulate; 
  class v1 v2;
  var v3;
  table min*v3=' '*v1=' ',v2;
  run;

Xia Keshan

Respected Advisor
Posts: 3,799

Re: Removing row headers in tabulate

Ksharp wrote:

data test;
input v1 v2 v3;
cards; 
1 1 1
2 2 4
3 4 10
; 
proc tabulate; 
  class v1 v2;
  var v3;
  table min*v3=' '*v1=' ',v2;
  run;

Xia Keshan

This should be the preferred method as it removes the "label" row produce by non-breaking space

10-10-2014 7-14-02 AM.png

Super User
Posts: 11,343

Re: Removing row headers in tabulate

Posted in reply to data_null__

Or instead of relying on label:

proc tabulate;

  class v1 v2;

  var v3;

  table v3='' * v1='',v2*sum='';

  run;

Single quotes with no space to override. Since V3 is a VAR it want a summary statistic row header which will still appear as blank.

Frequent Contributor
Posts: 129

Re: Removing row headers in tabulate

Posted in reply to BruceBrad

Thanks all. The responses which suggest using the within table statement =' ' formatting work (with or without the space in between). I thought I had tried this, but obviously not.

🔒 This topic is solved and locked.

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

Discussion stats
  • 8 replies
  • 275 views
  • 6 likes
  • 6 in conversation