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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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