Noob here. I need an elegant solution to the following problem in SAS:

The source dataset

**A**contains N observations (= rows) of a single variable X, i.e. x1, x2, ..., xN. From it, I need to generate an output dataset

**B**with one column (variable Y) and N*(N-1)/2 rows containing all possible permutations yi = xj*xk where j < k and k <= N.

Here's an example with N = 5:

Dataset

**A**[nobs = N = 5]:3

5

7

11

13

5

7

11

13

Dataset

What is the most efficient way of programming this scheme for the general case in SAS? One option is to use macros but I haven't yet found a neat, working way to do it with, say, a single "DATA" step using the "FETCHOBS()" function. The problem seems to require being able to manipulate SAS's automatic variable "_N_" back and forth.**B**[nobs = N*(N-1)/2 = 5*4/2 = 10]:15 (= 3*5)

21 (= 3*7)

33 (= 3*11)

39 (= 3*13)

35 (= 5*7)

55 (= 5*11)

65 (= 5*13)

77 (= 7*11)

91 (= 7*13)

143 (= 11*13)

21 (= 3*7)

33 (= 3*11)

39 (= 3*13)

35 (= 5*7)

55 (= 5*11)

65 (= 5*13)

77 (= 7*11)

91 (= 7*13)

143 (= 11*13)

Thanks.