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-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!

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.

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