BookmarkSubscribeRSS Feed
sasbasls
Calcite | Level 5

Hi,

   I need help on how to summarize data by no of observations. For ex: I have data by customer segment and I want to see how many customers are there in each of segment (count), how can I do using proc summary.

thanks,

sasbase

5 REPLIES 5
Ksharp
Super User

It is easy for proc summary.

proc summary data=have nway;

class segment;

output out=want n=how_many;

run;

sasbasls
Calcite | Level 5

What does n = how_many represent ? How can I get "how_many" ?

I used something like this :

PROC SUMMARY DATA=have missing NWAY;

CLASS var1 var 2 var 3 ;

ways 3 ;

OUTPUT OUT=want (DROP= _TYPE_)

         ;

RUN;

and then used _freq_ variable from above proc step to see as no of observations.

thanks,

sasbase

PaigeMiller
Diamond | Level 26
What does n = how_many represent ? How can I get "how_many" ?

N=HOW_MANY creates a data set variable named HOW_MANY in SAS data set WANT that contains N (the count of the number of observations in each group).

You access HOW_MANY the same way you access any data step variable.

--
Paige Miller
Astounding
PROC Star

Is there some reason you have to use PROC SUMMARY to accomplish this?  PROC FREQ is built for this task:

proc freq data=have;

   tables segment / missing;

run;

Good luck.

PaigeMiller
Diamond | Level 26

Astounding wrote:

Is there some reason you have to use PROC SUMMARY to accomplish this?  PROC FREQ is built for this task:

I would claim that PROC SUMMARY is also built for this task (as well as other tasks)

--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1886 views
  • 0 likes
  • 4 in conversation