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;
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)
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.