BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Silvertreetops
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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;

Silvertreetops
Obsidian | Level 7

Thank you so much Reeza

😄

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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