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 (January 2002, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 29 Jan 2002 16:48:59 -0500
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:   Re: Macro Problem
Comments:   To: "Pitruzzello, Anthony" <apitruzzello@CPS.K12.IL.US>
Content-Type:   text/plain; charset="iso-8859-1"

> From: Pitruzzello, Anthony [mailto:apitruzzello@CPS.K12.IL.US] > I'm hoping someone can help me with a macro problem. Working with > educational data sets, I usually prefer to read in a school > unit number or a > subject code as a numeric. On certain, occasions, however, I need to > concatenate UNIT and SUBJ to create a new sort variable. > Rather than read > them in twice, I use a little macro: > > %LET UNITC=PUT(UNIT,4.); > %LET SUBJC=PUT(SUBJ,4.); > %MACRO KEYY1; LENGTH KEY1 $8; KEY1=&UNITC||&SUBJC;%MEND KEYY1; > > Most of the time it works fine. But sometimes it doesn't. > Example, from a > SAS log: > 101 DATA F5; SET F4; &UNITC &SUBJC %KEYY1 > NOTE: Line generated by the macro variable "UNITC". > 101 PUT(UNIT,4.) > _ > 22 > 76 > > ERROR 22-322: Syntax error, expecting one of the following: a name, > arrayname, ), -, :, Ý, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_,

read the log: DATA F5; SET F4; PUT(UNIT,4.);

what's wrong with that paragraph? ... ?!

how about this: DATA F5; SET F4; UnitC =&UNITC.; SubjC=&SUBJC.; %KEYY1

I would recommend that you use the the format z4. for the numeric-to-character conversion.

Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov OpSys: Win_Pro Ver: 8.2 ---> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx !*! <---

> If, instead of the macro, I just write out the code, e.g.- > DATA F4; MERGE F2(IN=X) S; BY UNIT; IF X; > UNITC=PUT(UNIT,4.); > SUBJC=PUT(SUBJ,4.); > LENGTH KEY1 $8; KEY1=UNITC||SUBJC; -- it works fine. > Does anyone see what the problem is?


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