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. 

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