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

😄

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 8394 views
  • 0 likes
  • 2 in conversation