Desktop productivity for business analysts and programmers

Equivelant of Excel's COUNTIF in Advanced Expression Editor

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Equivelant of Excel's COUNTIF in Advanced Expression Editor

across_Hi,

I'm looking for an equivelant to Excel's COUNTIF function in SAS EG Advanced Expression Editor. Below is an example of what I'd like to achieve

INPUT DATASET

nameage
bill14
bob18
ben21
sarach18
shane14
sonya15

OUTPUT DATASET

nameagecount of age
bill142
bob182
ben211
sarach182
shane142
sonya151

I have looked at other sas forum entries but can't quite figure them out. I understand that advanced expression editor may be limited to calculating based on the row only, but am not sure. If someone could please how I can attain this in SAS EG I would be most appreciative.

Regards


Accepted Solutions
Solution
‎09-29-2014 11:02 PM
Super User
Posts: 19,192

Re: Equivelant of Excel's COUNTIF in Advanced Expression Editor

Assuming you wanted to use query builder then try the following:

1. Add Name, Age

2. Add Computed Column, Summarized Column, Add Age, Count-> make sure to name the column appropriately

3. Under summary groups, De select Automatically select and manually select only Age.

If you want code:

proc sql;

create table want as

select name, age, count(age) as count_age

from sashelp.class

group by age;

quit;

View solution in original post


All Replies
Solution
‎09-29-2014 11:02 PM
Super User
Posts: 19,192

Re: Equivelant of Excel's COUNTIF in Advanced Expression Editor

Assuming you wanted to use query builder then try the following:

1. Add Name, Age

2. Add Computed Column, Summarized Column, Add Age, Count-> make sure to name the column appropriately

3. Under summary groups, De select Automatically select and manually select only Age.

If you want code:

proc sql;

create table want as

select name, age, count(age) as count_age

from sashelp.class

group by age;

quit;

Occasional Contributor
Posts: 14

Re: Equivelant of Excel's COUNTIF in Advanced Expression Editor

Thank you so much Reeza

:-D

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 3518 views
  • 0 likes
  • 2 in conversation