|Date: ||Thu, 15 Feb 2001 08:32:09 -0500|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||John Hixon <125241N@KNOTES.KODAK.COM>|
|Subject: ||Combinations of elements from a string|
|Content-type: ||text/plain; charset=us-ascii|
From: John Hixon
Date: Wed, 14 Feb 2001 11:54:46 -0700
From: "Garnett P. McMillan" <gnet@UNM.EDU>
Subject: Combinations of elements from a string
>Suppose I define a macro variable:
>%LET X = x1 x2 x3 z1;
>How can I generate a set of macro variables, each of which describes a
>particular combination of the elements from X?
>VAR1 = x1,
>VAR2 = x1 x3,
>VAR3 = x1 z1,
>VAR4 = x2 x3,
>and so on until I have all possible combinations identified by
>individual macro variables.
>Is this possible?
>Thanks very much in advance,
*If you have SAS/STAT here is one way to approach your task.
I have posted others ways to obtain the combinations in the past.
Other folks have also posted very clever data step solutions.
Search the archives for "proc plan" or "combinations" to view
* Define your string using GLM syntax;
* You can find a clever way to parse the vars from your string.
I don't have much time to look closely at this. So, as a kludge
here, manually define your 4 "Main Effect" vars in a data step. You must
also define a "response" var (named "y");
x1=1; x2=2; x3=3; z1=4; y=10;
ods output DesignPoints = DesignMatrix;
proc glmmod data=junk outparm=jazz;
model y =&X;
title "Here is your Design Matrix. The Column Names are";
title2 "all factorial combinations of your Input Vars";
proc print data=DesignMatrix;
title "Here is a listing of the Factorial Combinations";
title2 "of your Input vars as a column with '*' between them.";
proc print data=jazz;
*I hope this starts you on your way to finding the soln you need?
Notice that the combinations with the * between them have you nicely set up
modeling using Proc Reg. Look at the examples supplied with Proc GLMOD.;
I hope this is helpful.
Eastman Kodak Company
Rochester, NY USA