turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Need SAS Logic to list all number combinations?

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-17-2012 02:51 AM

Dear Folks,

Request your help in SAS logic to list all number combinations. For example, lets say I have 12345. We know we can figure out several combinations such as 12345,21345, 31245,41235,51234..................and so on. I would like a SAS logic that would pick and list all combinations. Your help would be most appreciated. Merry Christmas. Thanks

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Nav_Sweeney

12-17-2012 03:53 AM

This sounds like a mathematical quiz, rather than a business requirement...?

Like most programming, there are several ways to accomplish this. On could involve arrays and do loop in the data step. If you want it dynamic (like number of number) you might need to use macro logic.

Data never sleeps

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Nav_Sweeney

12-17-2012 06:16 AM

Looks like you are want permutations. From the online documentation.

SAS provides three functions or CALL routines for generating all permutations:

- ALLPERM generates all possible permutations of the values, missing or non-missing, of several variables. Each permutation is formed from the previous permutation by interchanging two consecutive values.
- LEXPERM generates all distinct permutations of the non-missing values of several variables. The permutations are generated in lexicographic order.
- LEXPERK generates all distinct permutations of K of the non-missing values of N variables. The permutations are generated in lexicographic order.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Nav_Sweeney

12-17-2012 11:42 AM

Another option is to use PROC PLAN.

Tom

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to TomKari

12-18-2012 04:15 AM

Hi Tom,

Thanks very much indeed. Worked perfectly well.

Cheers,

Nav