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 (July 1999, 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 Jul 1999 15:19:39 -0400
Reply-To:   "Fehd, Ronald J." <rjf2@CDC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Fehd, Ronald J." <rjf2@CDC.GOV>
Subject:   %array notes
Content-Type:   text/plain; charset="iso-8859-1"

Yo, SAS Whizards(tm)!

I have several requests for my Very Large Macro %ARRAY. Imagine my surprise! ;-)

it's actually less than 100 lines of code, preceeded by two pages of how-to and followed by a page of example usage

Well, folks, be good at 'scope' aka 'referencing environment' when you use this macro. Note that there is no step boundary <RUN;> at the end of the macro, see %ARRAY.SAS in later e-mail. and that in the example usage below there is a <RUN;> _before_ the mac-vars can be used.

There is no easy way to determine how many is enough %local statements for the mac-vars created by this routine. Generally I look to context: if I'm using this macro with an Identifier-list then I use DIM = 3; I use this macro in my CHECKALL and SHOWCOMB routine to handle a list of variables, there I use 50 -- or was it 100? here is code from CHECKALL which shows typical usage within a macro

note: data set V&SERIES. is a list of variable names from proc CONTENTS

* MACRO: CHECKALL NOTE: uses macro ARRAY * * * * USAGE: 1) %CHECKALL(series-name);*assumes a data set contains vars * * 2) %CHECKALL(series-name,LIST=var1 var2 var3 .. varN); * ... %local DIM_VAR; %IF "&LIST"="DATA" %THEN %NOBS(DIM_VAR,DATA=&LIBRARY..V&SERIES.); %ELSE %LET DIM_VAR = 100; run; %DO I = 1 %TO &DIM_VAR;%local VAR&I.; %END; %IF "&LIST"="DATA" %THEN %ARRAY(VAR,DATA=&LIBRARY..V&SERIES.,VAR=Name); %ELSE %ARRAY(VAR,&LIST.); run;%*mac-vars created by %ARRAY are local to CHECKALL;

%*2: macro: if LIST=DATA then concatenate elements into LIST; %MACRO VAR_LIST;%DO I = 1 %TO &DIM_VAR; &&VAR&I. %END; %MEND; %IF "&LIST"="DATA" %THEN %LET LIST = %VAR_LIST;

I would appreciate critique from users of this macro. SAS-L has helped me become the Whizard that I am. A little more help is always welcome.

Ron Fehd the macro maven CDC Atlanta GA

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