Actually very simple.
You should be able to run the following code as SASHELP.Class should be in your install as a training data set.
proc freq data=sashelp.class;
tables age*sex/list;
run;
The list option makes a one row per combination of the variables. The table resulting will have a cumulative percent. Scroll down the cumulative percent column until the percent shown is at least as large as you want. Then select all the values of the two variables as your criteria. With this set that would be Age=11 and Sex=F as this set is small but that combination is 5.26% of the data. This approach does have a bias on sort order of the values but since I'm not really understanding the need and you said " any combination of two fields" this fills the requirement easily. Also easy to extend and if you need "at least 5% in one group and 15% in another group" you could just go down the list. Age=11 and Sex=F plus Age=12 and Sex=F is 21.05-5.16 or about 16%
OR you could look at the PERCENT column to see if a single row satisfies your need.
Age
Sex
Frequency
Percent
Cumulative Frequency
Cumulative Percent
11
F
1
5.26
1
5.26
11
M
1
5.26
2
10.53
12
F
2
10.53
4
21.05
12
M
3
15.79
7
36.84
13
F
2
10.53
9
47.37
13
M
1
5.26
10
52.63
14
F
2
10.53
12
63.16
14
M
2
10.53
14
73.68
15
F
2
10.53
16
84.21
15
M
2
10.53
18
94.74
16
M
1
5.26
19
100.00
@DaveKerr wrote:
Hoping this is even possible.
Essentially I have a table with several numeric customer data fields (eg credit score, income, age etc) and looking to layer any combination of two fields in order to create a population which accounts for at least 5% of the table.
For example customers with an age of less than 30 and an income of less than 25000 may account for - say - 3.5% of the table. My task is to therefore find a "sweet spot" of the two fields combined that would give me 5% of the table instead of 3.5%. So, perhaps age of less then 34 and income of less than 26000.
Question therefore is, how do I (evenly, if possible) scroll through each field and find that 5% sweet spot.
Any help hugely appreciated.
... View more