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

## SAS VA 7.4 Count a subset of multiple values in a field

Hi. I am a new user to SAS VA 7.4. I have a field with 7 possible values A,B,C,D,E,F,G.

Each instance of UpNum can have only one of these values. There are multiple instances of the same UpNum.

I need to count the total times that A,C,E,F occur for each UpNum to be able to calculate

TOT#(ACEF) per #UpNum and use this in a bar chart or a table.

In this example: #UpNum(ACEF)(=1) for N1, (=2) for N2, etc. (I have been running into Datatype errors for the operators).

UpNum         Field Value                          Output

N1                     A                                  N1          #(ACEF)

N1                     B                                  N2          #(ADEF)

N1                     D                                  N3.....     #(ACEF)

N1                     G                                  N4....      #(ACEF)

N2                     C

N2                     G

N2                     A

Thank you for any advice.

Ed C.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Employee

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Awesome! Glad to help 🙂
7 REPLIES 7
SAS Employee

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Hello Ed,

What sort of syntax are you using here? It doesn't appear that this is VA expression syntax.

Thanks,
Sam
Quartz | Level 8

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Hi. No, that is just my shorthand to describe what I am looking for. No syntax implied.

I am open to any suggestions of how to get to my output. #(ACEF) was just meant to say

that I need the sum of the counts of A, C, E, F for each UpNum value. Sorry for the confusion.

SAS Employee

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Your original question is a little bit confusing -- how many variables are we talking about in your data?

Does your data look like this?

UpNum    X

N1            A

N1            C

N2            E

N2            F

If N1, N2, etc are in a separate column from the A B C D E F G values, then you could calculate something like this:

IF X in ('A', 'C', 'E', 'F')

RETURN 1

ELSE 0

Then you could make a table with just Upnum and your calculated item. Turn off detail data in the table properties.

Would that work?

Quartz | Level 8

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Yes, in one column N1....Nn and in a separate column A-G.

This would be a new Calculated Measure? Why turn off Detail Data?

Thanks! Strategy question. Would this column be better created in the original table

or in SAS VA? (Is there a rule of thumb for this?).

SAS Employee

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Yes, a calculated measure. You turn off Detail Data so that the values will be aggregated for each value of UpNum.

Generally speaking, it is simpler to calculate new items in your original table. SAS language, SQL syntax, etc. are much more robust than the expression editor syntax in Visual Analytics.

That said, I believe there are some aggregated calculations that can only be created in VA.
Quartz | Level 8

## Re: SAS VA 7.4 Count a subset of multiple values in a field

This worked just right! Thanks for helping me move toward the next experience level....

SAS Employee

## Re: SAS VA 7.4 Count a subset of multiple values in a field

Awesome! Glad to help 🙂
Discussion stats
• 7 replies
• 1130 views
• 0 likes
• 2 in conversation