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!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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