DATA Step, Macro, Functions and more

count no of cases

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

count no of cases

Hi i want to count total number of cases in data set .

The data has variable status so want to count total no of cases based on the values of status.

filter should be where status=cr then the total count should be stored in new variable.

if status-ct then count of ct in new variable.

 

 


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 9,880

Re: count no of cases

In SQL, this would be

select count(*) from ...... where status = "ct";
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
2 weeks ago
Super User
Posts: 9,880

Re: count no of cases

In SQL, this would be

select count(*) from ...... where status = "ct";
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 69

Re: count no of cases

Posted in reply to KurtBremser
Thanks Kurt ,
any solution how can we implement it using the query builder.
and any data step
Super User
Posts: 9,880

Re: count no of cases

In the query builder, select status and apply the count() summary function to it; on the second tab, add the where condition.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 69

Re: count no of cases

Posted in reply to KurtBremser
Hi Kurt,
i used the following sum(case when status=ct then 1 else 0) which gave me the the count of ct cases in the data set similarly i did it for the other case where i got the required o/p using the query builder and designed the automated process flow.

Thanks for your help.
Anirudh
Super User
Posts: 23,249

Re: count no of cases



That's three questions in one.

 


@anirudhs wrote:

Hi i want to count total number of cases in data set .

 

 


 

Use a summarization task

 


@anirudhs wrote:

 

The data has variable status so want to count total no of cases based on the values of status.

 

 


Again, a Summary task will produce that. 

 


@anirudhs wrote:

 

if status-ct then count of ct in new variable.

 

 


In a separate data set, how do you need that stored? You can use Query builder with a filter or you could save the results from the summary tasks into a dataset for use later.

 

It seems like all your results could be handled with a summarization procedure.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 96 views
  • 0 likes
  • 3 in conversation