BookmarkSubscribeRSS Feed
Citrine10
Obsidian | Level 7

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

10 REPLIES 10
PeterClemmensen
Tourmaline | Level 20

Show us your data please. Not just the desired result 🙂

Citrine10
Obsidian | Level 7
hello. Not much in the data
just the claimid and the region column
PaigeMiller
Diamond | Level 26

Use PROC SUMMARY

 

#ProcSummaryRulez

--
Paige Miller
Citrine10
Obsidian | Level 7
i dont want all the various stats. i just need a simple count with the total of those counts
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
andreas_lds
Jade | Level 19

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
Obsidian | Level 7
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'
andreas_lds
Jade | Level 19

@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";
singhsahab
Lapis Lazuli | Level 10

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. 

singhsahab
Lapis Lazuli | Level 10

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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 10 replies
  • 1603 views
  • 2 likes
  • 5 in conversation