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
It is easy for proc summary.
proc summary data=have nway;
class segment;
output out=want n=how_many;
run;
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
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.
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.
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)
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.
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.