BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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
Meteorite | Level 14

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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