DATA Step, Macro, Functions and more

Count function

Accepted Solution Solved
Reply
Occasional Contributor hmc
Occasional Contributor
Posts: 5
Accepted Solution

Count function

hi, I have a data file something like this,

policynumber    name

3                       Jon

4                       Alex

3                       Jon

5                       Tim

3                        Jon

 

i want to count how many number of policies each individual has, can anyone please help me in this


Accepted Solutions
Solution
‎06-27-2017 12:41 PM
Valued Guide
Posts: 765

Re: Count function

Hi, or other PROCS ...


proc means data=x n nonobs;
class name;
run;

 

proc freq data=x;
table name;
run;

View solution in original post


All Replies
Super Contributor
Posts: 439

Re: Count function

There are a few different ways of doing this - you could do something like

 

proc sql;
	create table polcount
	as select name, count(name) as totalpols
	from have
	group by name;
quit;

 

Occasional Contributor hmc
Occasional Contributor
Posts: 5

Re: Count function

Posted in reply to ChrisBrooks

Thank you, can i use that code in SAS? 

Super Contributor
Posts: 439

Re: Count function

You certainly can - if it fits the bill could you mark my reply as an accepted solution please? It saves others from responding to an issue which has already been solved.

Solution
‎06-27-2017 12:41 PM
Valued Guide
Posts: 765

Re: Count function

Hi, or other PROCS ...


proc means data=x n nonobs;
class name;
run;

 

proc freq data=x;
table name;
run;

Occasional Contributor hmc
Occasional Contributor
Posts: 5

Re: Count function

thank you i got it

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 186 views
  • 0 likes
  • 3 in conversation