LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 19 Mar 2002 18:31:24 +0100
Reply-To:     Peter Crawford <peter.crawford@DB.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      Re: macro
Content-type: text/plain; charset=iso-8859-1

sorry to be adding so little to the simple macro suggested by Ian Whitlock <WHITLOI1@WESTAT.COM>

but it is too tempting, to resist reducing one of Ian's ;-) !

Why not reduce it to %macro yrs( from=1988, to=1999, format=year2 ) ; %local yr ; %do yr = &from %to &to ; %sysfunc( mdy( 1,1, &yr ), &format ) %end ; %mend yrs ;

%put %yrs(from=1995, to=2002) ; or %let yrList = %yrs(from=1995, to=2002) ;

Increasing the indentation of the %sysfunc line will add more blanks between the entries in the list

Because y2k compliance still has a residual influence, I extended the macro introducing a parameter for the format of the year. This allows 4 digits years to be requested with %let y2kYears = %yrs( from=95, to=02, format=year4 ) ;

Regards Peter Crawford

Datum: 19/03/2002 14:48 An: SAS-L@LISTSERV.UGA.EDU

Antwort an: Ian Whitlock <WHITLOI1@WESTAT.COM>

Betreff: Re: macro Nachrichtentext:

Lan,

%macro yrs ( from=1988, to=1999 ) ; %local yr list temp ; %do yr = &from %to &to ; %let temp = %sysfunc(mod(&yr,100)) ; %let list = &list %sysfunc(putn(&temp,z2.)) ; %end ; &list %mend yrs ;

%put %yrs(from=1995, to=2002) ;

IanWhitlock@westat.com

-----Original Message----- From: Lan Jiang [mailto:Lan.Jiang@MED.VA.GOV] Sent: Monday, March 18, 2002 5:36 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: macro

Hi all,

I have a macro as follows:

%macro yrs;

88 89 90 91 .. 99

%mend;

I want to generate a series of macros as follows:

%macro yrs89to99; 89 90 91 .. 99 %mend;

%macro yrs90to99; 90 91 .. 99 %mend;

%macro yrs91to99; 91 .. 99 %mend;

But I don't want to do it like above to increase the length of my program. Is there any smarter way to do it (and I sure there is)?

Thank you in advance.

Lan

--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


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