LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 15 Feb 2001 08:32:09 -0500
Reply-To:   125241N@KNOTES.KODAK.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   John Hixon <125241N@KNOTES.KODAK.COM>
Subject:   Combinations of elements from a string
Comments:   To: gnet@UNM.EDU
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

asked:

>Greetings all!!

>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?

>For example, >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, >Garnett

------------------------------ */

*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 those approaches.;

* Define your string using GLM syntax; %let X=x1|x2|x3|z1;

* 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");

data junk; x1=1; x2=2; x3=3; z1=4; y=10; run;

ods output DesignPoints = DesignMatrix; proc glmmod data=junk outparm=jazz; model y =&X; run; title "Here is your Design Matrix. The Column Names are"; title2 "all factorial combinations of your Input Vars"; proc print data=DesignMatrix; run;

title "Here is a listing of the Factorial Combinations"; title2 "of your Input vars as a column with '*' between them."; proc print data=jazz; run;

*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 to perform modeling using Proc Reg. Look at the examples supplied with Proc GLMOD.;

I hope this is helpful.

John Hixon john.hixon@kodak.com Eastman Kodak Company Rochester, NY USA 716-477-1984


Back to: Top of message | Previous page | Main SAS-L page