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 (June 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 21 Jun 2010 21:41:22 -0400
Reply-To:   OR Stats <stats112@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   OR Stats <stats112@GMAIL.COM>
Subject:   Data Step & macro array
Content-Type:   text/plain; charset=ISO-8859-1

Hello:

I have a user defined table like this

id x1 x2 ... x10

For each id, I have a macro variable _macrovarI with p number of terms. For example, for id=1

%put &_macrovar;

x1 x2*x8 x3 x5

where in this case p=4 terms. For each one of the p terms I have p coefficients corresponding to each of the terms in a table

term coeff x1 c1 x2*x8 c2 x3 c3 x5 c5

From the original user-defined table, I would like to create a new column y that is the sum of the products of the terms and their corresponding coeff's. For example, for id=1

y= c1*x1 + c2*x2*x8 + c3*x3 + c4*x5

Two things that have been tricky are that in the original dataset. For one thing, I don't have column that are product of the x's (for example, x2*x8). And the second thing that makes this complicated is that for each id, the p terms changes and therefore the coefficient table changes with them. How do I create a new table that is

id x1 .... x10 y

Data newtable; set origtable; /*loop thru p terms? for each id*/

Many thanks!

Side note: The macro variable is output from a model proc as is the coefficient table. I need to to apply the output x's and their coefficients to new dataset, which the proc does not allow for to calculate y.


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