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 (November 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 7 Nov 2002 11:33:05 -0500
Reply-To:     "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Subject:      Re: Elementary macro problem (I think)
Content-Type: text/plain; charset="iso-8859-1"

Peter:

Two things.

You probably want to subscript your array with &I rather than just i.

You're getting the error on the first iteration of the macro loop. SAS is smart enough to know that min(var1-var1) is only variable. Your macro loop should probably start at 2 since the distance between one point is probably kinda meaningless anyway.

-----Original Message----- From: Peter Flom [mailto:flom@NDRI.ORG] Sent: Thursday, November 07, 2002 11:24 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Elementary macro problem (I think)

OK, I solved the earlier problem.....

now I have a file with variables

city distance_1 through distance_95 start_1 through start_95

and they are in order of start. e.g. the first city was the one with the first start date, and has a distance_1 of 0, and all other distances missing. the second city has distance_1 = to the distance between it and the first city, distance_2 = 0, all other distances missing, and so on.

What I need is to find several things (e.g. the minimum, the average, other things as well) about each city but only about certain distances. e.g. the minimum distance at time 5 is (for each city) the minimum of distance_1 through distance_5.

I *THINK* I need a macro..... Note that this is my FIRST ATTEMPT AT WRITING a macro program.

I tried this

PROGRAM SNIPPET STARTS %macro minasof; %do i = 1 %to 95; minasof(i) = min(of distance_1 - distance_&i); %end; %mend minasof; %minasof run;

PROGRAM SNIPPET ENDS

but I got an error message saying that the min function didn't have enough arguments.....

Any help appreciated

Peter

Peter L. Flom, PhD Assistant Director, Statistics and Data Analysis Core Center for Drug Use and HIV Research National Development and Research Institutes 71 W. 23rd St New York, NY 10010 (212) 845-4485 (voice) (917) 438-0894 (fax)


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