Sarah Hailey
Sarah Hailey

Reputation: 494

SAS PROC REPORT how to display analysis variables as rows?

I don't know where to start with this. I've tried listing the columns in every possible order but they are always listed horizontally. The dataset is:

data job2; 
input year apply_count interviewed_count hired_count interviewed_mean hired_mean; 
datalines; 
2012    349 52  12  0.149   0.23077
2013    338 69  20  0.20414 0.28986
2014    354 70  18  0.19774 0.25714
; 
run; 

Here's an example of the proc report code for just one analysis variable:

proc report data = job2; 
columns apply_count year; 
define year / across " ";
define apply_count / analysis "Applied" format = comma8.; 
run; 

Ideally the final report would look like this:

        2012    2013    2014
Applied 349     338     354
Interv. 52      69      70
Hired   12      20      18

Inter % 15%     20%     20%
Hired % 23%     29%     26%

Upvotes: 2

Views: 428

Answers (1)

data _null_
data _null_

Reputation: 9109

I don't know if this is the best way to do this.

data job2; 
   input year apply_count interviewed_count hired_count interviewed_mean hired_mean; 
   datalines; 
2012    349 52  12  0.149   0.23077
2013    338 69  20  0.20414 0.28986
2014    354 70  18  0.19774 0.25714
;;;; 
   run; 
proc transpose data=job2 out=job3;
   by year;
   run;
data job3;
   set job3;
   length y atype $8;
   y     = propcase(scan(_name_,1,'_'));
   atype = scan(_name_,-1,'_');
   if atype eq 'mean' then substr(y,8,1)='%';
   run;
proc print;
   run;
proc report data=job3 list;
   columns atype y year, col1 dummy;
   define atype / group noprint;
   define y     / group order=data ' ';
   define year / across ' ';
   define dummy / noprint;
   define col1 / format=12. ' ';
   compute before atype;
      xatype = atype;
      endcomp;
   compute after atype;
      line ' ';
      endcomp;
   compute col1;
      if xatype eq 'mean' then do;
         call define('_C3_','format','percent12.');
         call define('_C4_','format','percent12.');
         call define('_C5_','format','percent12.');
         end;
      endcomp;
   run;

enter image description here

Upvotes: 1

Related Questions