Hi guys,
I have a report that contains data for many companies, and I would like to add filter on the company. So I added drop-down list to my report with company values and assigned CompanyParameter to this list.
Now, I would like to show only exact values, I mean do something like this:
if company = 'CompanyParameter'p then show only records for CompanyParameter
Unfortunately when building the filter, I can't find 'equality' operator, I can use for example "Contains":
if company Contains 'CompanParameter'p then show only records for CompanyParameter
And here comes the main issue. Let's assume that I have two companies: ABC and ABCD. Because I have 'contains' operator, then when I select ABCD company the records for ABC will be also presented (because 'ABCD' contains 'ABC').
Do you know how should I resolve this issue?
Thanks,
Filip
Hello Filip,
You can use the "=" operator for both numeric and character values. It can be a little confusing because the hint text in the expression builder says "number".
For example:
IF ( 'car'n = 'Toyota' )
RETURN 1
ELSE 0
Beside the "=" operator, you could also use "In"
IF ( 'car'n In ('Toyota', 'Ford') )
RETURN 1
ELSE 0
Usually you would want to use In to match multiple values, but you can select a single value.
A tip about comparing character strings -- the comparison operators are case sensitive. So you would want to wrap the strings in the LowerCase() operator to make a case-insensitive match.
Sam
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.
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.