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 (April 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 27 Apr 2001 08:30:19 -0400
Reply-To:     Paige Miller <paige.miller@KODAK.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paige Miller <paige.miller@KODAK.COM>
Organization: Eastman Kodak Company
Subject:      Re: Problem with a SAS/IML macro
Content-Type: text/plain; charset=us-ascii

Maria Helena wrote: > > Hi everbody! > > After trying unsuccessfully to finish my IML macro, I've decided to > ask for help in this list. > > I am sure that this is a very simple problem, but simply I've give up. > > The macro is only a few lines long: > > proc iml; > %MACRO matrix; > %DO n=1 %TO 2; > G&n=G**&n; /* G is a m x m matrix */ > Future&n=(G&n*G); > rate&n=Future&n / G&n; > Lambda&n = max(rate&n); > %END; > %MEND matriz; > > The problem is that I am interested in store the macro variable Lambda&n in > a variable of a dataset but after trying with "create"; "edit"; fileout, > append, etc. I can't do it.

First, let me recommend that you not use MACRO loops within IML. They probably work fine, except that IML has its own looping structures that also work fine, and by using IML loops, you only have to compile the IML code instead of compiling both macro code and then IML code. I think its also easier to program and understand if you only use IML loops.

To answer your specific question, here's some code that might work, but to be fair, I am trying to illustrate the idea, and so I have not tested this specific code (that's your job). The CREATE statement creates a "template" for a dataset but doesn't actually put data into it, I think it just assigns columns. So you only need to use the CREATE statement once. Then the APPEND statement actually enters the data into the data set, and this happens each time in the loop, so your output data set receives the values in lambda each time through the loop.

proc iml; DO n=1 TO 2; Gtemp=G**n; /* G is a m x m matrix */ Future=(Gtemp*G); rate=Future / Gtemp; Lambda = max(rate); if n=1 then create outputdataset from lambda; append from lambda END; quit;

-- Paige Miller Eastman Kodak Company paige.miller@kodak.com

"It's nothing until I call it!" -- Bill Klem, NL Umpire "Those black-eyed peas tasted all right to me" -- Dixie Chicks


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