BookmarkSubscribeRSS Feed
antoniodneto
Calcite | Level 5

Hi guys,

I have one table with many where clauses. I need to count a number of cases for each where clause.

 

For example:

apply filter 1 how many cases was filtered, then I apply filter 2 and count the cases again.

 

Thank you guys!!

2 REPLIES 2
SASKiwi
PROC Star
%macro count_rows(filter = );
proc sql;
  select count(*) as row_count
  from MyTable
  where &filter;
quit;
%mend;

%count_rows(filter = %str(<Myfilter1>));
%count_rows(filter = %str(<Myfilter2>));



antoniodneto
Calcite | Level 5

Hi,]

How Can I apply here?

 

PROC SQL;
CREATE TABLE TESTE AS
SELECT DISTINCT T1.*
FROM TESTE_2 T1

INNER JOIN TESTE_3 T2 ON T1.NAME = T2.NAME
INNER JOIN TESTE_4 T3 ON T1.NAME = T3.NAME
LEFT JOIN TESTE_5 t4 ON T1.NAME = T4.NAME
LEFT JOIN TESTE_6 T5 ON T1.NAME = T5.NAME

WHERE

T3.NAME IS MISSING AND
T4.NAME IS MISSING AND
T5.NAME IS MISSING

;
RUN;

 

 

That is my sample, So I need to count the cases for each filter:

Apply T3.NAME IS MISSING (count how many cases out for this filter) then apply the second (count again)....

 

It helps?

Thank you so much!

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 Update

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