BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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;

3 REPLIES 3
ArtC
Rhodochrosite | Level 12
Do you want e.12 to appear in the report? I assume so otherwise you could eliminate it with a WHERE.
Ronein
Onyx | Level 15

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)

 

ArtC
Rhodochrosite | Level 12

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1587 views
  • 0 likes
  • 2 in conversation