Ok, I think I may not have expressed myself clearly.
I'd try to make a better example for my problem...
Suppose you have these two tables of event and population:
data TEST;
length CITY DISTRICT EVENT $5 QTY 8;
input CITY DISTRICT EVENT QTY;
datalines;
City1 Dist1 Even1 2
City1 Dist1 Even2 4
City1 Dist1 Even3 6
City1 Dist1 Even4 4
City1 Dist2 Even1 1
City1 Dist1 Even1 2
City1 Dist1 Even1 4
City2 Dist1 Even4 15
City2 Dist1 Even1 7
City2 Dist2 Even1 9
;;
run;
data POPULATION;
length CITY DISTRICT $5 POP 8;
input CITY DISTRICT POP;
datalines;
City1 Dist1 100
City1 Dist2 123
City2 Dist1 45
City2 Dist2 96
;;
run;
Now on VA I have a cross table with a City > District hierarchy and a filter on events.
What I need is this:
No event filter active:
City Qty Pop Rate City1 23 223 23/223x10000 City2 31 141 31/141x10000
No event filter active but hierarchy open:
City District Qty Pop Rate City1 Dist1 22 100 22/100x10000 City1 Dist2 1 123 1/123x10000
City2 Dist1 22 45 22/45x10000
City2 Dist2 9 96 9/96x10000
But if I activate a filter on an event, let's say event1, I need these output:
City Qty Pop Rate City1 9 223 9/223x10000 City2 16 141 16/141x10000
City District Qty Pop Rate City1 Dist1 8 100 8/100x10000
City1 Dist2 1 123 1/123x10000 City2 Dist1 7 45 7/45x10000
City2 Dist2 9 96 9/96x10000
So, basically, the Qty depends on the event variable, while the population depends only from City and District variabiles.
Let's say I have these data:
City Dist Event Qty Pop City1 Dist1 Even1 2 100 City1 Dist1 Even2 4 100 City1 Dist1 Even3 6 100 City1 Dist1 Even4 4 100 City1 Dist2 Even1 1 150 City1 Dist1 Even1 2 100 City1 Dist1 Even1 4 100 City2 Dist1 Even4 15 200 City2 Dist1 Even1 7 200 City2 Dist2 Even1 9 250
If I compute the rate by row, I obtain the correct measure. But if I want to aggregate by city, for city1 ie I will obtain Qty=2+4+6+4+2+1+4=23 but I will also obtain Pop=100+100+100+100+150+100+100=750, that's wrong, since the right population is just 100+150=250.
Yesterday I had to overcome a similar challenge.
here comes a recipe for solving it.
https://blogs.sas.com/content/sgf/2018/09/05/selective-filtering-in-sas-visual-analytics-8-2/
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.