hi there
i am not sure whether to use group by or whether to use tabulate. Either way i'm not sure if those 2 are the correct options on how to do this:
I want to count the number of claims per region and get the total of all regions as follows:
Region Number
Pta 5
Jhb 6
Kzn 6
total 17
Show us your data please. Not just the desired result 🙂
Use PROC SUMMARY
#ProcSummaryRulez
@Citrine10 wrote:
i dont want all the various stats. i just need a simple count with the total of those counts
PROC SUMMARY will do that, it only gives you the statistics you ask for.
But really, you should show us a portion of the input data, and the exact output you want.
Without any data, it is somewhat difficult to help you. Here is an example on how to count with proc summary:
proc summary data=sashelp.class;
class Age;
output out=work.counted(drop=_type_ rename=(_freq_=count));
run;
In your case proc report seems to be a better tool:
proc report data=sashelp.class;
columns Age Age=Count;
define Age / group;
define Count / n;
rbreak after / summarize;
run;
@Citrine10 wrote:
Thank you Andreas.
is there a way to give the column a prefered name? At the moment the column header is called 'ClaimID' as thats the field name. I would like to call it 'Number of claims'
Just add the text in quotes to the define statement.
define Count / n "Number of pupils";
You can use Proc Report . Group column will be Region. Analysis column will be number of claim with sum statistics and use rbreak statement for total sum.
You can Refer below code:
data have;
input Region : $8. Number;
datalines;
a 1
a 2
b 3
b 1
b 2
;
quit;
proc report data=have out=want(drop=_break_);
column Region Number;
define Region/group;
define Number/analysis sum;
rbreak after/ol summarize;
compute after;
Region='Total:';
endcomp;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.