Date: Mon, 9 May 2005 14:42:03 -0400
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: how to detect macro variable length violation
Quentin,
Have you tried to set the system option mvarsize=max?
MVARSIZE=
----------------------------------------------------------------------------
----
Specifies the maximum size for macro variables that are stored in memory
Valid in: configuration file, SAS invocation, OPTIONS statement, Systems
Options window
Category: Macro: SAS macro
PROC OPTIONS GROUP= MACRO
----------------------------------------------------------------------------
----
Syntax
Syntax Description
Details
----------------------------------------------------------------------------
----
Syntax
MVARSIZE= n |nK | nM | nG | MIN | MAX | hex
Syntax Description
n | nK | nM | nG
specifies the maximum size for macro variables stored in memory in terms of
bytes, kilobytes, megabytes, and gigabytes, respectively.
MIN
sets MVARSIZE to 0, which causes all macro variables to be written to disk.
MAX
specifies the maximum amount of memory available.
hex
sets the maximum macro variable size stored in memory as a hexadecimal
number. This number must be followed by an X.
----------------------------------------------------------------------------
----
Details
If the size of the macro variable is larger than the maximum value that is
specified, variables are written out to disk.
The value that you specify with the MVARSIZE= system option can range from
0 to the largest positive integer that is representable on your operating
environment.
Operating Environment Information: The value of MVARSIZE= can affect
system performance. Before you specify the value for production jobs, run
tests to determine the optimum value. For further information and default
settings, see the SAS documentation for your operating environment.
On Mon, 9 May 2005 14:25:04 -0400, Quentin McMullen
<quentin_mcmullen@BROWN.EDU> wrote:
>On Mon, 9 May 2005 13:34:21 -0400, Ben <benpub7@YAHOO.COM> wrote:
>
>>Oh, if you can keep quote mark balanced, it wont be a problem to put all
>>the characters of a book into a macro variable. the maxium length is
>>about 2**32-1. correct me if I am wrong.
>>
>>
>>Thanks
>
>I don't think that is correct. Below is log I get on Win v9.1.3. Suggests
>max length that a macro variable can store on Win is 65534. It doesn't
give
>an error on initial assignment to LongMacVar, it happily truncates (doh!).
>
>I do get an error on second assignment to LongerMacVar.
>
>My fear is about the silent truncation. When it's just me, I can trust
>myself not to exceed 65534 characters. But someone else might not, and
>might feel that a macro that happily truncates, without so much as a peep,
>isn't very friendly.
>
>
>NOTE: Copyright (c) 2002-2003 by SAS Institute Inc., Cary, NC, USA.
>NOTE: SAS (r) 9.1 (TS1M3)
>NOTE: This session is executing on the XP_PRO platform.
>
>NOTE: SAS 9.1.3 Service Pack 2
>
>NOTE: SAS initialization used:
> real time 0.53 seconds
> cpu time 0.28 seconds
>
>1 %let longmacvar=%sysfunc(repeat(x,100000));
>2 %put %length(&longmacvar);
>65534
>3 %let longermacvar=&longmacvar.y;
>ERROR: The text expression length (65535) exceeds maximum length (65534).
>The text expression
>ERROR: The text expression length (65535) exceeds maximum length (65534).
>The text expression
>ERROR: The text expression length (65535) exceeds maximum length (65534).
>The text expression
> has been truncated to 65534 characters.
> has been truncated to 65534 characters.
> has been truncated to 65534 characters.
>ERROR: Errors printed on page 1.
>ERROR: Errors printed on page 1.
>ERROR: Errors printed on page 1.
>
>NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
>NOTE: The SAS System used:
> real time 0.60 seconds
> cpu time 0.31 seconds
>
>Kind Regards,
>--Quentin