DATA Step, Macro, Functions and more

Add total rows in proc report

Accepted Solution Solved
Reply
Regular Contributor
Posts: 200
Accepted Solution

Add total rows in proc report

Hello

Please see this code with proc report.

I want to add total row after categories that belongs to same variable (summary row for Female and Male categories and another summary row  for Degree and NotDegree categories)

data summary_dataset; 
   input dem $ year apply_count interviewed_mean hired_mean; 
   select(first(dem));
      when('M','F') gr=1;
      otherwise     gr=2;
      end;
   datalines; 
Male    2012    288 0.15972 0.21739
Female  2012    61  0.09836 0.33333
Male    2013    279 0.19355 0.2963
Female  2013    59  0.25424 0.26667
Male    2014    293 0.18089 0.28302
Female  2014    61  0.27869 0.17647
Degree  2012    108 0.28704 0.19355
NoDeg   2012    241 0.08714 0.28571
Degree  2013    108 0.36111 0.28205
NoDeg   2013    230 0.13043 0.3
Degree  2014    124 0.23387 0.2069
NoDeg   2014    230 0.17826 0.29268
run; 


proc report data =summary_dataset list; 
   columns  gr dem (("Applied" apply_count),year gap ("Interviewed" interviewed_mean),year gap ("Hired" hired_mean),year); 
   define gr  / group ' ' noprint;
   define dem / group " ";
   define apply_count / analysis "" format = comma8.; 
   define interviewed_mean / analysis "" format = percent8.; 
   define hired_mean / analysis "" format = percent8.; 
   define year / across  ""; 
   define gap / ' ' style={cellwidth=.25in};
   compute after gr;
      line ' ';
      endcomp;
   run; 

 


Accepted Solutions
Solution
2 weeks ago
Regular Contributor
Posts: 248

Re: Add total rows in proc report

proc report data =summary_dataset list; 
   columns  gr dem (("Applied" apply_count),year gap ("Interviewed" interviewed_mean),year gap ("Hired" hired_mean),year); 
   define gr  / group ' ' noprint;
   define dem / group " ";
   define apply_count / analysis sum " " format = comma8.; 
   define interviewed_mean / analysis sum " " format = percent8.; 
   define hired_mean / analysis sum " " format = percent8.; 
   define year / across  ""; 
   define gap / ' ' style={cellwidth=.25in};
   break after gr / summarize;
   compute after gr;
		dem = 'Total';	
      line ' ';
      endcomp;
   run;

View solution in original post


All Replies
Solution
2 weeks ago
Regular Contributor
Posts: 248

Re: Add total rows in proc report

proc report data =summary_dataset list; 
   columns  gr dem (("Applied" apply_count),year gap ("Interviewed" interviewed_mean),year gap ("Hired" hired_mean),year); 
   define gr  / group ' ' noprint;
   define dem / group " ";
   define apply_count / analysis sum " " format = comma8.; 
   define interviewed_mean / analysis sum " " format = percent8.; 
   define hired_mean / analysis sum " " format = percent8.; 
   define year / across  ""; 
   define gap / ' ' style={cellwidth=.25in};
   break after gr / summarize;
   compute after gr;
		dem = 'Total';	
      line ' ';
      endcomp;
   run;
☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 55 views
  • 1 like
  • 2 in conversation