DATA Step, Macro, Functions and more

Proc REport

Reply
Frequent Contributor
Posts: 95

Proc REport

Hello

Please see this code.

I want to do some changes to output and don;t know how to do it in proc report code.

I want to add global total for following  grades:a.0,b.1-6  ,c.7-10,d.11 (without grade e.12)

 

 

 

 

Data TBl;
INPUT grade $ Model $ Obligo;
Cards;
a.0           a   10
a.0           b   20
b.1-6       a   30
c.7-10     a   40
d.11        a   50
d.11        b   60
e.12        a   70
e.12        b   80
;
Run;
libname proclib 'SAS-library';
options nodate pageno=1 linesize=64 pagesize=60
fmtsearch=(proclib);
proc report data=TBl nowd headline headskip;
column grade Model Obligo ;
define grade / group
'Grade';
define Model / group
'Model';
define Obligo / analysis sum
format=comma10.
'Ob';
/*total after each groupkCat*/
break after grade / ol
summarize
suppress
skip;
/*global total*/
rbreak after / summarize;
compute after;
type = 'Total';
endcomp;
run;

Valued Guide
Posts: 653

Re: Proc REport

Do you want e.12 to appear in the report? I assume so otherwise you could eliminate it with a WHERE.
Frequent Contributor
Posts: 95

Re: Proc REport

Yes.

I want to get subtotal without e.12  and in the row after getting information of e.12  and in row after get total of all(included e.12)

 

Valued Guide
Posts: 653

Re: Proc REport

You may want to try using a multilabel format.  Note the (multilabel) option on the VALUE statement and the MLF option on the DEFINE statement.  Unless you are writing to the LISTING destination, you can also eliminate a number of REPORT options e.g. HEADLINE, HEADSKIP, SKIP, OL

Data TBl;
INPUT grade $ Model $ Obligo;
Cards;
a.0        a   10
a.0        b   20
b.1-6      a   30
c.7-10     a   40
d.11       a   50
d.11       b   60
e.12       a   70
e.12       b   80
;
Run;
proc format;
 value $grade (multilabel)
   'a.0'     = 'Primary'   
   'b.1-6'   = 'Primary'
   'c.7-10'  = 'Primary'
   'd.11'    = 'Primary'
   'a.0'     = 'Secondary'   
   'b.1-6'   = 'Secondary'
   'c.7-10'  = 'Secondary'
   'd.11'    = 'Secondary'
   'e.12'    = 'Secondary';
   run;


/*libname proclib 'SAS-library';*/
/*options nodate pageno=1 linesize=64 pagesize=60*/
/*fmtsearch=(proclib);*/
proc report data=TBl;
column grade=ggroup grade Model Obligo ;
define ggroup / group 'Grade Group' f=$grade. mlf;
define grade / group 'Grade';

define Model / group 'Model';
define Obligo / analysis sum
                format=comma10.
                'Ob';
/*total after each groupkCat*/
break after grade / 
/*   ol*/
   summarize
   suppress
/*skip*/
;
/*global total*/
/*rbreak after / summarize;*/
/*compute after;*/
/*type = 'Total';*/
/*endcomp;*/
run;
Ask a Question
Discussion stats
  • 3 replies
  • 113 views
  • 0 likes
  • 2 in conversation