BookmarkSubscribeRSS Feed
sashokku
Obsidian | Level 7

Am a new SAS VA user. I need to write function like this can you help me out. These are the measures, I need to create. 

 

 

1. Count (A =' Yes')
Column A has two distinct values in it. I need to know the count of 'Yes' and use it as a Measure in chart.

 

2. Count( A <1 ) AND Count ( B < 1 )

How to write a condition like this & keep it as a measure.

 

8 REPLIES 8
Reeza
Super User

Create a calculated measure or variable first that's 1 if A is yes, 0 otherwise. 

Then sum that variable. 

 

 

sashokku
Obsidian | Level 7

Thanks for the reply. Tried it & still getting some error. Can you give some example or something that is done previously.

sas_it
Quartz | Level 8

How to do this?

SASKiwi
PROC Star

Count is an aggregated measure so all you need to do is in the Data Pane click the down arrow and select New Aggregated Measure. In this window you can define formulas to do what you want.

sashokku
Obsidian | Level 7

Thanks for the reply @SASKiwi. Yes, I did it already but getting error within that. Since I am unable to write conditions within that. I can share the snapshot of it for clarity.  

 

I need to write condition & then get the count of it.

 

Count( A ='Yes' ) 

 

 

 

 

 

 

 

Sam_SAS
SAS Employee

Hello sashokku,

 

You need to create a calculated measure like this:

 

IF ( 'A'n = 'yes' )
RETURN 1
ELSE 0

 

 

The sum of that measure is what you want.

 

Your second condition can also be evaluated with IF statements:

 

IF ( ( 'A'n < 1 ) AND ( 'B'n < 1 ) )

RETURN 1
ELSE 0

 

About the Count() function, it returns the number of nonmissing values for a measure. So if your IF statements return missing instead of 0 you could use count. But it is simpler to just use sum with the expressions above.

 

I hope this helps,

Sam

sas_it
Quartz | Level 8
I am having 5 stages with 0 and 1 as follow :
Application id. S1 s2 s3 s4 s5
1. 0. 1. 1. 0. 1
2. 1. 0. 1. 0. 1

Support we have 10 applications and i want the total of each stage . Will the solution provided by you will work for this.
Sam_SAS
SAS Employee
If the stages are numeric (not 1 and 0 as character values), then the totals for the table should provide the correct total values. Yes? Also, any aggregated object will default to showing the sum of the stage values. I believe that should be what you want, too.

It should not be necessary to use any calculated expressions to get the values you want.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 6042 views
  • 1 like
  • 5 in conversation