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 (December 1999, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 6 Dec 1999 11:59:43 -0600
Reply-To:     JGerstle@SW.UA.EDU
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         JGerstle@SW.UA.EDU
Subject:      CrossProduct Array question
Content-type: text/plain; charset=US-ASCII

I have a quick question (SAS 6.12 via Win98).

I need to determine the products of 43 pairs of variables (i.e. c1*b1 , c2*b2 , ......etc... c43*b43 ). I was thinking that there should be a way to do this without typing out every product as separate lines in the data step. I'm thinking that if I were to create an array for both sets of variables that there should be a way to multiply each pair of variables. I tried it like this but to no avail:

array seta (43) c1 - c43; array setb (43) b1 - b43; do i = 1 to 43; prod(i) = seta(i)*setb(i); end; etc..

The message I get is: ERROR: Undeclared array referenced: PROD. ERROR: Variable PROD has not been declared as an array.

What I'd like is to get 43 separate variables calculated form the 43 products, each with its own name. Should I create a variable for each step of the array calculations? Can I do this without using macros?

John Gerstle Program Analyst, Sr. Applied Gerontology Program University of Alabama


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