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 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 16 Jan 2009 13:31:27 +0100
Reply-To:   Andre Wielki <wielki@INED.FR>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Andre Wielki <wielki@INED.FR>
Subject:   Re: question about sas macro variables
Comments:   To: "he.terry@gmail.com" <he.terry@GMAIL.COM>
In-Reply-To:   <c2f8ed96-e1dd-4e3f-b16e-ebf2f80b064c@g38g2000yqn.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1; format=flowed

Terry you are learning macro language

It is not easy and i hope you have current pratice of sas since almost one year as macro is only generating text which must be future sas correct code!

here some comment about your problem:

There are statements which you may use only in a macro %macro ... %mend; your error %do... in open code

this also induct that you must be carefull about the scope of your macro variable

a %let in open code (=outside %macro...) generate a global scope but inside a %macro the scope could be local

the best is that you read and work some good start papers see http://www2.sas.com/proceedings/sugi28/056-28.pdf www2.sas.com/proceedings/sugi29/243-29.pdf

HTH Andre

he.terry@gmail.com a écrit : > I have two programs. One is right and the other is wrong. I am not > sure about the reason. > > The right code is as follow: > > options symbolgen mprint; > %let m=2; > %macro b; > %do i = 1 %to &m; > &i > %end; > %mend b; > > %let c = %b > ; > > > %macro a; > %put &c; > %mend a; > %a; > > The wrong code is as follow: > options symbolgen mprint; > %let m=2; > %let c = %do i = 1 %to &m; > &i > %end; > ; > > > %macro a; > %put &c; > %mend a; > %a; > >

-- André WIELKI INED (Institut National d'Etudes Démographiques) Service Informatique 133 Boulevard Davout 75980 Paris Cedex 20 mél : wielki@ined.fr tél : 33 (0) 1 56 06 21 54


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