Date: Fri, 15 Aug 1997 09:25:45 -0700
Reply-To: Scott Carl <SCARL@THECREEK.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Scott Carl <SCARL@THECREEK.COM>
Subject: Re: limit on SAS macro variable!
Content-Type: text/plain; charset="iso-8859-1"
Paul and the rest,
Take a look at this:
data test;
do i=1 to ((32*1024)/2)-2;
x=1;
output;
end;
proc sql noprint;
select x into: x separated by ','
from test;
quit;
%let length=%length(&x);
%put &length;
Here is a macro variable called x that has a length of 32K. I output 2
characters per row, "1,", hence the division by 2 in the datastep.
Scott Carl
Marketing Statistician
Coldwater Creek
One Coldwater Creek Drive
Sandpoint, ID 83864
scarl@thecreek.com
(208) 265-7136
> ----------
> From: Paul Dorfman[SMTP:PDORFMA@UCS.ATT.COM]
> Sent: Friday, August 15, 1997 11:53 AM
> To: SAS-L@UGA.CC.UGA.EDU
> Subject: limit on SAS macro variable!
>
> In reply to Don Stanley's posting,
> Anthony Ayiomamitis, in particular, wrote:
>
> >The code below presents a couple of interesting results ....
> >data _null_;
> >call symput ('test', repeat ('x', 199) ||
> >repeat ('x', 199) ||
> >repeat ('x', 199));
> >run;
> >%put &test;
> >First and foremost, the REPEAT function will not allow the creation
> >of a string in excess of 200 bytes (this could be argued as being
> reasonable as its >purpose is to build strings - via character
> variables - which in SAS are currently set >at 200 bytes in length).
> >The second interesting observation is that within a data step, SAS
> >will not allow for the definition of a string in excess of 200 bytes
> to be held in >memory (via a character variable or otherwise).
> >Now, assuming the data step has a self-imposed limit of 200 bytes
> >(as suggested above), one can test if the limit of 200 bytes can be
> circumvented by an >attempt to build such a string outside of a data
> step, which leads to ...
> >data _null_;
> >call symput ('test1', repeat ('x', 198)); call symput ('test2',
> repeat ('y', 1));
> >run;
> >%let test = &test1&test2;
> >%put &test;
> >This example does generate a macro variable JUST in excess of 200
> >bytes (as expected) but the warning that it exceeds 200 bytes and
> that a quotation may >be unbalanced is provided in the log (as you had
> observed once exceeding 1229 bytes).
>
> Anthony:
>
> I've already posted a reply to you and Don earlier but it must not
> have been lucid enough. Since it's not long, let me repost it:
>
> 1. "Macro variables have a maximum length of 32k characters." (SAS
> Macro
> Language, Reference, 1st Edition). That is, the largest
> non-negative
> integer with 8-byte representation.
> 2. Normally, it is limited by the default value of MVARSIZE= option.
> In
> MVS, it is 8k. Of course, MVARSIZE=MAX means 32k. Using MVARSIZE=
> much less than MAX may hinder performance since every time a
> macrovariable
> is created with a length less than the value set by MVARSIZE= it
> will
> be
> written to a disk as a catalog member in the WORK library with the
> type MSYMTAB.
>
> end-repost
>
> Let me stress that I still think macrovariable length has absolutely,
> positively nothing to do with 200 bytes. It's just when SAS thinks it
> encounters an unbalanced quote it produces the warning once the length
> of the unbalances piece exceeds 200 and stops increasing the length of
> a macrovariable if it's being built up iteratively.
>
> After I sent the message reposted above, I received a private message
> from Wolf F. Lesener from Berlin:
>
> >Hallo Paul,
> >please allow some questions to your mail.
> >1. You have mentioned SAS Macro Language, Reference 1st Edition.
> >I've read the same paragraph but I understand it in a different
> manner.
> >I think the limit of 32K is the limit of all macro variables you have
> >created in a session.
> >2. The MVARSIZE= option doesn't reflect a single macro variable it
> >gives the maximum length of all macro variables you are using in the
> >session.
> >Both 1+2 are my asumptions and they are the result of following
> >test code - the result seems to be incorrect - but what's the error?
> >%macro lg;
> > %local i v l;
> > %let v=c; /* any character differently to blank */
> > %do i=1 %to 10;
> > %let v=&v&v;
> > %let l=%length(&v);
> > %put i=&i l=&l;
> > %end;
> > %mend;
> >%lg
> >Paul, please be so kindly and have a look at my short macro. I've a
> >little confusion to understand.
>
> I ran the macro and here is the output:
>
> I=1 L=2
> I=2 L=4
> I=3 L=8
> I=4 L=16
> I=5 L=32
> I=6 L=64
> I=7 L=128
> WARNING: The current word or quoted string has become more than 200
> characters long. You may have unbalanced quotation marks.
> I=8 L=200
> WARNING: The current word or quoted string has become more than 200
> characters long. You may have unbalanced quotation marks.
> I=9 L=200
> WARNING: The current word or quoted string has become more than 200
> characters long. You may have unbalanced quotation marks.
> I=10 L=200
>
> My answer to Wolf boiled down to essentially the following:
>
> It LOOKS LIKE once the length of the macrovariable v exceeds 200
> bytes the alleged limitation goes into effect. To demonstrate that
> is not true it is enough just to remove the adverse unbalanced
> quotation condition and the limit magically vaporizes. Watch this
> (I'm merely quoting the &v&v before assigning it to v again; in
> addition, I'm taking the liberty to display the actual value to
> which the macrovariable v resolves):
>
> 47 %MACRO LG;
> 48 %LOCAL I V L;
> 49 %LET V=C; /* ANY NONBLANK CHARACTER */
> 50 %DO I=1 %TO 10;
> 51 %LET V=%QUOTE(&V&V);
> 52 %LET L=%LENGTH(&V);
> 53 %PUT I=&I L=&L;
> 54 %PUT V=&V;
> 55 %END;
> 56 %MEND;
> 57 %LG
> I=1 L=2
> V=CC
> I=2 L=4
> V=CCCC
> I=3 L=8
> V=CCCCCCCC
> I=4 L=16
> V=CCCCCCCCCCCCCCCC
> I=5 L=32
> V=CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> I=6 L=64
> V=CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> I=7 L=128
> V=CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> I=8 L=256
> V=CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
> I=9 L=512
> V=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