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

Hello,

Question, I would like to create to measures on a trend line where each of 2 measures are each defined by a flag where something like,  Distinct Count where a category variable equals a certain flag. Is this possible in SAS VA 7.2?

Thank you for any input.

1 ACCEPTED SOLUTION

Accepted Solutions
Sam_SAS
SAS Super FREQ

Hello,

Distinct count is an aggregated operator, and I don't think you can evaluate the value of a character (or a numeric) flag on a row-by-row basis as part of an aggregated expression.

One workaround would be to create two calculated measures similar to the following:

ObsoleteUnitAge

IF ( 'Age Status'n In ('Obsolete') )

RETURN 'Unit Age'n

ELSE .

and

CurrentUnitAge

IF ( 'Age Status'n In ('Current') )

RETURN 'Unit Age'n

ELSE .

You could then calculate the distinct count for these calculated columns to get the distinct count of 'Unit Age' where the 'Age Status' flag is "Obsolete" and also the distinct count where the flag is "Current".

Is that the sort of result that you are looking for?

View solution in original post

4 REPLIES 4
TejaSurapaneni
Lapis Lazuli | Level 10

Hi,

First you can't equal charter variable to measure.

So can please explain more to better understand.

Thanks & Regards,

Teja Surapaneni.

jplarios
Quartz | Level 8

Hi Teja,

For example, I have a trend that sums up 'if' a certain flag is set - so measure 1 is  sum if flag = 'y'  and measure 2 is sum if flag = 'x'.

How can I do this but with distinct count?

Sam_SAS
SAS Super FREQ

Hello,

Distinct count is an aggregated operator, and I don't think you can evaluate the value of a character (or a numeric) flag on a row-by-row basis as part of an aggregated expression.

One workaround would be to create two calculated measures similar to the following:

ObsoleteUnitAge

IF ( 'Age Status'n In ('Obsolete') )

RETURN 'Unit Age'n

ELSE .

and

CurrentUnitAge

IF ( 'Age Status'n In ('Current') )

RETURN 'Unit Age'n

ELSE .

You could then calculate the distinct count for these calculated columns to get the distinct count of 'Unit Age' where the 'Age Status' flag is "Obsolete" and also the distinct count where the flag is "Current".

Is that the sort of result that you are looking for?

jplarios
Quartz | Level 8

Sam,

Thank you : so create a calculated then distinct - excellent. I applied and worked nice.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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