Help using Base SAS procedures

Just inherited a Proc tabulate program...

Reply
New Contributor
Posts: 3

Just inherited a Proc tabulate program...

Hello-

I recently inherited a program that uses Proc tabulate. I'm not familiar with this proc and I was asked to modify the way the table looks. I have to move the count and % values so they are colums next to each other .

The table needs to look something like this:


       Yes       No         Total
UnitCount   %Count  %Count   %
Unit1   222.2%550%736.8%
Unit2   333.3%550%842.1%
Total    9
10
19

Currently, the %'s fall under the Unit counts. I've tried moving things around but can't seem to get the right result.

Here is what I have right now:

Does anyone have any thoughts?

proc tabulate data=have

style=font_size=8pt};

class  quest unit answer  /

style={ font_size=9pt};

classlev question unit answer /

style={font_size=9pt};

tables quest=' ',

unit=' '*(n pagepctn*f=pctfmt.) all*(npagepctn*f=pctfmt.),

answer =' 'all 

/ row=float

box={label='Number^{newline 1}Overall^_%' style={ =9pt}};

keylabelall='Total'

n=' '

pagepctn=' ';

keyword all n pagepctn/

style={ font_size=8pt};

Any feedback would be very helpful!

Thanks.

PROC Star
Posts: 7,365

Just inherited a Proc tabulate program...

It would help others on the forum if you also post a copy of your have dataset.

New Contributor
Posts: 3

Just inherited a Proc tabulate program...

ok, the dataset looks something like this:

data have;

  infile datalines dlm=',' dsd;

  input unit $ question answer;

return;

datalines;

"Unit1",1,1

"Unit1 ",1,0

"Unit1 ",1,1

"Unit1 ",1,0

"Unit1 ",1,1

" Unit2",1,1

" Unit2",1,1

" Unit2",1,0

" Unit2",1,1

" Unit2",1,0;

run;

I also apply formats to "Question" and "Answer".  Thanks.

Super User
Posts: 9,691

Just inherited a Proc tabulate program...

Is it what you are looking for ?

proc format;
value x
 1 = 'Yes'
 0 = 'No'
 ;
picture p
 low-high='0099%';
run;
data have;
  infile datalines dlm=',' dsd;
  input unit $ question answer;
  format answer x.;
datalines;
"Unit1",1,1
"Unit1 ",1,0
"Unit1 ",1,1
"Unit1 ",1,0
"Unit1 ",1,1
" Unit2",1,1
" Unit2",1,1
" Unit2",1,0
" Unit2",1,1
" Unit2",1,0
;
run;


proc tabulate data=have;
class unit answer;
table unit all,n='Count'*f=best8.*(answer='' all='Total') pctn='%'*f=p.*(answer='' all='Total') ;
run;

Ksharp

New Contributor
Posts: 3

Just inherited a Proc tabulate program...

Thank you. I will try this out and let you know.

Ask a Question
Discussion stats
  • 4 replies
  • 120 views
  • 0 likes
  • 3 in conversation