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 (May 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, 21 May 2002 12:45:37 +0200
Reply-To:     Andre Wielki <wielki@INED.FR>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Andre Wielki <wielki@INED.FR>
Subject:      Re: SMALL macro question
Comments: To: "J. van Dalen" <j.dalen@FAC.FBK.EUR.NL>
In-Reply-To:  <>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Jan Find here a solution options mprint; %MACRO TEST(varnam); %LET sumind = _&varnam._ ;

DATA dum; &sumind=0; OUTPUT; RUN; PROC PRINT DATA=dum; RUN; %MEND;

%TEST(IT); ;

HTH Andre

At 12:10 21/05/2002 +0200, J. van Dalen wrote: >ls, > >I am sorry to disturb you all with the following macro question. I would >appreciate however, if someone could help me out with this one. > >Part of the macro is to create a variable that has a name (to be >determined in the macro heading) enclosed in underscores. For example, >one might be interested in having a variable: _IT_ (which should be the >result of the macro shown below, with IT as input). However, when I run >the macro below, I do have the desired variable name stored in the macro >variable &sumind, but the subsequent use of this macro variable gives >rise to errors as illustrated by the subsequent note. [Alternatively, >when I change the %LET statement into %LET sumind = _IT_, no errors >occur. Yet, this is not an elegant solution, since I then loose my >flexibility in naming macro vraiables.] > >Question: Is there a way to obtain the desired _IT_ (or any arbitrary >variable name within underscores) and still maintain the equally desired >flexibility? > >Kind regards, > > >Jan van Dalen > >THE MACRO -------> > >%MACRO TEST(varnam); > %LET sumind = _%STR(&varnam)_ ; > %PUT sumind : &sumind; > DATA dum; &sumind=0; OUTPUT; RUN; > PROC PRINT DATA=dum; RUN; >%MEND; > >%TEST(IT); RUN; /* Calculating indices */ > >NOTE: Line generated by the macro variable "SUMIND". >1 _IT_ > - > 180

___________ WIELKI Andre INED - Service Informatique 133 Bd Davout, 75 980 Paris Cedex 20 FRANCE Tel: 01 56 06 21 54

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