BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

I’m trying to display the distinct count of a population where a particular condition in the record is true.  My text in the edit calculated item of VA Report Editor is:

IF ( 'REAL Numeric'n = 1 )

RETURN Distinct [_ByGroup_] ('Random ID'n[Formatted])

ELSE 0

The goal is to produce the distinct count of the student population where a condition is true divided by the distinct count of the student population and show it as a static or sometimes referred to as a key value.

For some reason, the result of this is 0.

 

Since this is for a dashboard I cannot just display both numbers in tabular format.

1 ACCEPTED SOLUTION

Accepted Solutions
KeithM
SAS Employee

David,

I was able to get it to work. This is what my sample data looked like.  It started off with just RandomIDChar and Real.   I assume that your goal is to get one value and add it to a Key Value object.

 

KeithM_0-1613147909715.png

 


Calculations:

Step #1: Create your new character data item based on your filter criteria:

Name: RandomIDNew
Calculation:

KeithM_1-1613148024416.png

 

Step #2: Numerator: (Note: NumMiss will calculate the number of items that are missing. If there are any missing, then we need to subtract that one distinct count from the resulting distinct count calculation)

KeithM_2-1613148059317.png

 


Step #3:  Denominator:

 

KeithM_3-1613148075254.png

Step #4:  Create Percent  (Note:  step 2,3 & 4 could all be just one calculation)

 

KeithM_4-1613148337130.png

 

 

View solution in original post

3 REPLIES 3
DavidPhillips2
Rhodochrosite | Level 12

With this syntax the is = 1 is being compared to the aggregated set, so that logic doesn't work.

I've been playing with the notmissing function to see if there is a way to remove the missing values.

The if only has a if else function, if I could drop the else it would work.

DavidPhillips2
Rhodochrosite | Level 12

I'm investigating options involving subtracting out the values that would be missing.  Investigating functions like nummiss.

KeithM
SAS Employee

David,

I was able to get it to work. This is what my sample data looked like.  It started off with just RandomIDChar and Real.   I assume that your goal is to get one value and add it to a Key Value object.

 

KeithM_0-1613147909715.png

 


Calculations:

Step #1: Create your new character data item based on your filter criteria:

Name: RandomIDNew
Calculation:

KeithM_1-1613148024416.png

 

Step #2: Numerator: (Note: NumMiss will calculate the number of items that are missing. If there are any missing, then we need to subtract that one distinct count from the resulting distinct count calculation)

KeithM_2-1613148059317.png

 


Step #3:  Denominator:

 

KeithM_3-1613148075254.png

Step #4:  Create Percent  (Note:  step 2,3 & 4 could all be just one calculation)

 

KeithM_4-1613148337130.png

 

 

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
  • 3 replies
  • 964 views
  • 0 likes
  • 2 in conversation