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

Hi all,

I have a character column, "PlayerTier1" contains "Classic" and "Emerald".  I want how many of "Classic" in that column without resorting to filter out "Classic".  Much like a CountIF function in excel.

 

 

Capture.PNG

Thank you all,

1 ACCEPTED SOLUTION

Accepted Solutions
mohamed_zaki
Barite | Level 11
proc sql;
select count(PlayerTier1)
from have
where PlayerTier1='Classic';
quit;

View solution in original post

13 REPLIES 13
mohamed_zaki
Barite | Level 11
proc sql;
select count(PlayerTier1)
from have
where PlayerTier1='Classic';
quit;
sdang
Quartz | Level 8

Thank you!  But is there a Query Builder function I can use instead of resorting to proc sql?

mohamed_zaki
Barite | Level 11

@sdang wrote:

 instead of resorting to proc sql?


btw, What this mean?

FreelanceReinh
Jade | Level 19

@mohamed_zaki wrote:

@sdang wrote:

 instead of resorting to proc sql?


btw, What this mean?


Please see "to resort to something."

sdang
Quartz | Level 8

HI,

I'm sorry if my choice of word might be mis-led.  I meant is there another way to get a summary table from Query Builder where a count column only counts Classic but others numeric columns sum by or count regardless of Classic? And using only Query Builder function, and not having to write codes in Proc SQL

 

Thanks

Reeza
Super User

The answer is in @Haikuo post.

 

Probably worth marking this question answered at this point as well.

 

One last tip, the comparison is case sensitive, so determine if you need to account for that. If you do, use UPPER() or LOWER() to set them all to the same case.

 

 

sdang
Quartz | Level 8
Thank you!
sdang
Quartz | Level 8

Thank you!

Haikuo
Onyx | Level 15

Could be as straightforward as:

 

proc sql;
select sum(playtier1='classic') as classic_ct from have ;
quit;
sdang
Quartz | Level 8

Thank you!

Haikuo
Onyx | Level 15

Add new computed column -> advanced expression -> sum(playertier1='classic') -> enter the name of your new column -> done.

Reeza
Super User

Query Builder writes SQL, so its the same as adding a filter within Query Builder.

 

For this type of summary its useful to determine why you want it, for display or in a table?

 

If display I would say a Summary Task would be more appropriate. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 13 replies
  • 4490 views
  • 2 likes
  • 5 in conversation