Help using Base SAS procedures

countif function

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

countif function

Good morning,

I was wondering whether there is a countif function like the one in Excel that can count across rows...

Have

Mary
Mary
Mary
Jim
Jim
Jim
Jim
Jim
Steven
Steven

Want


Mary

3
Jim5
Steven2

Thank you!


Accepted Solutions
Solution
‎12-16-2013 11:18 AM
Super User
Posts: 19,855

Re: countif function

PROC FREQ.

Proc freq data=sashelp.class;

Table Age/Out=Age_Categories;

run;

View solution in original post


All Replies
Solution
‎12-16-2013 11:18 AM
Super User
Posts: 19,855

Re: countif function

PROC FREQ.

Proc freq data=sashelp.class;

Table Age/Out=Age_Categories;

run;

Contributor
Posts: 21

Re: countif function

You also can use PROC SQL or PROC MEANS:

proc sql;

create table want as

select distinct name,

count(name) as count_names

from have

group by name;

quit;

proc means data=have;

class name;

output out=want

     (where=name ne ' '

     drop=_type_

     rename=_freq_=count_names);

run;

Respected Advisor
Posts: 3,799

Re: countif function

Check the documentation regarding the NWAY option and you won't need the where data set option.

Also check out TYPES and WAYS statements.

Contributor
Posts: 45

Re: countif function

Proc Freq! Of course! Smiley Happy

Thank you.

I wish i knew how to use sql. I keep on bumping to it. It is on my list!

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 11271 views
  • 6 likes
  • 4 in conversation