Generates all distinct combinations of the non-missing values of n variables taken k at a time in lexicographic order.

Category: | Combinatorial |

Restriction: | The LEXCOMB function cannot be executed when you use the %SYSFUNC macro. |

specifies an integer variable that is assigned values ffrom 1 to the number of combinations in a loop.

is a constant, variable, or expression between 1 and n, inclusive, that specifies the number of items in each combination.

specifies either all numeric variables, or all character variables that have the same length. The values of these variables are permuted.

Requirement | Initialize these variables before you execute the LEXCOMB function. |

Tip | After executing the LEXCOMB function, the first k variables contain the values in one combination. |

When all of the variables
have non-missing, unequal values, then the number of combinations
is COMB(n,k). If the number of variables that have missing
values is m, and all the non-missing values are unequal, then LEXCOMB
produces COMB(n-m,k) combinations
because the missing values are omitted from the combinations.

If you execute the LEXCOMB
function after generating all the distinct combinations, then LEXCOMB
returns –1.

If you execute the LEXCOMB
function with the first argument out of sequence, then the results
are not useful. In particular, if you initialize the variables and
then immediately execute the LEXCOMB function with a first argument
of j, you will not get the j^{th} combination (except
when j is 1). To get the j^{th} combination,
you must execute the LEXCOMB function j times, with the first argument taking values from 1 through j in that exact order.

Copyright © SAS Institute Inc. All rights reserved.