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 (June 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 18 Jun 2003 19:21:09 +0200
Reply-To:     Michael.Eckhardt@T-SYSTEMS.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Michael.Eckhardt@T-SYSTEMS.COM
Subject:      AW: Macro qoutation was: length of the macro variable
Content-Type: text/plain; charset="ISO-8859-1"

Two points to clear the fog. Macro expressions (macro var content) always are strings that will substitute the macro code at runtime.

If you define: %LET a = x; %PUT &a; at runtime you will simply read x;

The dot '.' is the delimiter of a macro variable to distinguish macro text from other text expressions.

expanding the little example above

with

%LET a1 = y;

%PUT &a1; %PUT &a.1;

&a1 is substituted by y, but &a. (note the macro var delimiter) will change to x and therefore &a.1 resolves to x1

Quotes, unless treated by one of the many %quote()-Functions (RTFM for these), are interpreted as plain text. So let's see again what we can count with %LENGTH:

(Referring to the original example now).

5024 %LET smth= acc111; 5025 %PUT %LENGTH(&smth); 6 5026 %PUT %LENGTH(&smth.); 6 5027 %PUT %LENGTH("&smth"); 8 5028 %PUT %LENGTH("&smth."); 8

mit freundlichen Grüssen Regards

Michael Eckhardt Berater Business Intelligence T-Systems GEI GmbH Geschäftsstelle Darmstadt/FDL Mitte Frankfurter Str. 27 65760 Eschborn Telefon: +49 (6196) 961-540 Fax: +49 (6196) 961-517 E-Mail: Michael.Eckhardt@t-systems.com <mailto:Michael.Eckhardt@t-systems.com> Mobil: + 49 (171) 5762151 Internet: http:\\www.t-systems.de

-----Ursprüngliche Nachricht----- Von: Huang, Ya [mailto:yhuang@AMYLIN.COM] Gesendet: Mittwoch, 18. Juni 2003 18:33 An: SAS-L@LISTSERV.UGA.EDU Betreff: Re: length of the macro variable

The extra two are from the double quote and '.' ?

4 %let smth= acc111; 5 %let smth1=%length (%trim(&smth)); 6 %put ==>&smth1<==; ==>6<==

-----Original Message----- From: Ira Roberts [mailto:ir10@MAIL.COM] Sent: Wednesday, June 18, 2003 9:06 AM To: SAS-L@LISTSERV.UGA.EDU Subject: length of the macro variable

Dear SAS-L'ers,

why the length of the macro var is greater than its actual length (even after I trimmed it?

74 %let smth= acc111; 75 %let smth1=%length (%trim("&smth.")); 76 %put &smth1.; 8 *<**** it is always [(the actual length) + 2 ]; 77 %put ==>&smth.<==; ==>acc111<==

Thanks, IRa


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