Generates all subsets of n items in a minimal change order.
Category: | Combinatorial |
specifies a numeric variable. Initialize k to either of the following values before executing the CALL GRAYCODE routine:
specifies numeric variables that have values of 0 or 1 which are updated when CALL GRAYCODE is executed. A value of 1 for numeric-variable-j indicates that the jth item is in the subset. A value of 0 for numeric-variable-j indicates that the jth item is not in the subset.
specifies a character variable that has a length of at least n characters. The first n characters indicate which items are in the subset. By default, an "I" in the jth position indicates that thejth item is in the subset, and an "O" in the jth position indicates that the jth item is out of the subset. You can change the two characters by specifying the in-out argument.
specifies a numeric constant, variable, or expression. By default, n is the length of character-variable.
specifies a character constant, variable, or expression. The default value is "IO." The first character is used to indicate that an item is in the subset. The second character is used to indicate that an item is out of the subset.
%macro test(n); %*** Initialize the character variable to a sufficiently long nonblank, nonnumeric value. ; %let x=%sysfunc(repeat(_, &n-1)); %let k=-1; %let nsubs=%eval(2**&n + 1); %put nsubs=&nsubs k=&k x="&x"; %do j=1 %to &nsubs; %syscall graycode(k, x, n); %put &j: k=&k x="&x" sysinfo=&sysinfo; %end; %mend; %test(3);