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:   Wed, 21 Jul 1999 11:27:25 -0700
Reply-To:   "Lund, Pete" <Peter.Lund@CFC.WA.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Lund, Pete" <Peter.Lund@CFC.WA.GOV>
Subject:   Re: Macro Mystery
Comments:   To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Content-Type:   text/plain; charset="windows-1252"

Howard (and all)- Ian Whitlock, in his illustrious role as SAS-L blunder catcher, found a slight mistake in my earlier post. The UNQUOTE should be inside the loop. As it was, only the last value was passed to the SAS complier.

A corrected version is:

%macro yrbyr(loyr,hiyr,left,middle,right);

%* Generate code like x99 x00 x01 or x99=y99 x00=y00 x01=y01 ;

%do year4 = &LOYR %to &HIYR; %let year = %substr(&YEAR4,3,2); %let assign = &LEFT&YEAR; %if %length(&MIDDLE) %then %do; %let assign = &assign&MIDDLE&YEAR; %end; %let assign = &assign&RIGHT; %unquote(&assign) %end; %mend yrbyr;

Pete Lund WA State Caseload Forecast Council 515 15th Ave SE Olympia, WA 98504-0962 (360) 902-0086 - voice (360) 902-0084 - fax peter.lund@cfc.wa.gov <mailto:peter.lund@cfc.wa.gov>

-----Original Message----- From: Howard Schreier [mailto:Howard_Schreier@ITA.DOC.GOV] Sent: Wednesday, July 21, 1999 8:28 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Macro Mystery

I'm definitely not a macro maven.

This came up in the course of some minor Y2K remediation. I want to get rid of constructs like

value94-value98

representing annual time series in variable lists.

Here's my macro:

%macro yrbyr(loyr,hiyr,left,middle,right);

%* Generate code like x99 x00 x01 or x99=y99 x00=y00 x01=y01 ;

%do year4 = &LOYR %to &HIYR; %let year = %substr(&YEAR4,3,2); &LEFT&YEAR%if %length(&MIDDLE) %then %do;&MIDDLE&YEAR%end;&RIGHT %end; %mend yrbyr;

Here's a test job:

proc format; value $newnam %yrbyr(1997,2001,%bquote('Old),%bquote('='New),%bquote(')) ; run;

The ugliness from the log is shown below. What's really strange, to me at least, is the MPRINT output. The first two years generate the expected character strings, the third does not, the fourth and fifth are OK but all the letters have been upcased.

What is happening, and why?

TIA

From the SAS log:

ERROR: This range is repeated, or values overlap: '-'. NOTE: Line generated by the macro variable "YEAR". 134 New - 200 ERROR 200-322: The symbol is not recognized.

NOTE: Line generated by the macro variable "YEAR". 134 New - 76 ERROR 76-322: Syntax error, statement will be ignored.

MPRINT(YRBYR): 'Old97'='New97' 'Old98'='New98' 'Old99'='99' 'OLD00'='NEW00' 'OLD01'='NEW01' 135 ; NOTE: The previous statement has been deleted. 136 run;

NOTE: The SAS System stopped processing this step because of errors.


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