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

That seems to be it, I mean it worked with the sample. I will try to customize it for my data but will take me a couple of hours and is 2 in the night but I will read the document and try to figure it out and will request your help as a last resort. Thanks again for helping me.

akberali67
Calcite | Level 5

Hi,

The code only makes combinations but not permutations.

I understood the issue, it is with the concept. Mathematically, it needs more theories (Permutations, Combinations and Selections) implemented within code, I will have to buy books and read to be able to figure it out. Thanks for the help.

-Akber.

art297
Opal | Level 21

You didn't look at the link I posted from which the macro came.  The link had two macros, one for combinations and another for permutations.  Take a look at it: : TS-DOC: TS-498 - Generating Combinations and Permutations

hdodson_pacificmetrics_com
Calcite | Level 5

akberali67,

     You haven't said this, but is the below correct?

          You want to submit an SQL query, or set of queries, for each possible filter set, and keep those filter sets which return results in a manner (time and/or size) that meet certain criteria, which you already have stored in variables elsewhere.

     If the above is not correct, please explain what performance each filter set needs to give. This will greatly impact the solutions offered.

Thanks for your patience,

Huey

akberali67
Calcite | Level 5

Hi Huey,

Thats exactly what I am trying to do. So, trying to save the filter combinations that actually show good performance on my criteria. Aside from making those combinations ofcourse, sort of two problems wrapped in one.

-Akber.

Astounding
PROC Star

Parts of the problem need to be thought through a little more.

First, you are asking for more than the permutations.  When A takes on five values, you are not just asking for the 5! permutations.  You are actually asking for a total of 326 permutations:

5 choose 5 = 120

5 choose 4 = 120

5 choose 3 = 60

5 choose 2 = 20

5 choose 1 = 5

5 choose 0 = 1

Secondly, characteristics of the data could use a little more detail.  For example, could the domain for A overlap the domain for B?  Could any of the original values be missing?

One approach would be just to focus on a single variable at a time.  Create a data set called A_permutations holding all the permutations for A, and similarly for each incoming variable.  In theory, if you don't run out of resources, it would be easy to combine them in PROC SQL.

Haikuo
Onyx | Level 15

Math has never been my forte, I tend to use those out-of-box SAS functions to the job for me, here is the example based on Art's sample data, and it is for Permutation, and it can be easily tweaked to Combination as well ( just  in-situ replace some functions):

data test;

  infile cards missover;

  input (A B)(:$2.);

  array t(9999) $2. _temporary_;

  array in a b;

  do over in;

  if in not in t then do;

i+1;

t(i)=in;

end;

  end;

  call symputx('n',9999-cmiss(of t(*)));

  cards;

A1 B1

A2 B2

A3 .

;;;;

data want;

  array v $2. v1-v&n;

  array t(&n.) $2. _temporary_;

  do until (done);

  set test end=done;

  array in a b;

do over in;

  if not missing(in) and in not in t then do;

ct+1;

t(ct)=in;

end;

end;

  end;

  n=&n.;

  do k=1 to n;

  nperm=perm(n,k);

  do j=1 to nperm;

  call lexperk(j, k, of t

  • );
  • do i=1 to k;

    v(i)=t(i);

    end;output;

      end;

      end;

      keep v:;

    run;

    Haikuo

    sas-innovate-2024.png

    Don't miss out on SAS Innovate - Register now for the FREE Livestream!

    Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

     

    Register now!

    What is Bayesian Analysis?

    Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

    Find more tutorials on the SAS Users YouTube channel.

    Click image to register for webinarClick image to register for webinar

    Classroom Training Available!

    Select SAS Training centers are offering in-person courses. View upcoming courses for:

    View all other training opportunities.

    Discussion stats
    • 21 replies
    • 5111 views
    • 3 likes
    • 5 in conversation