Date: Tue, 27 May 2003 13:00:03 +0100
Reply-To: peter@CRAWFORDSOFTWARE.DEMON.CO.UK
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject: usage problem with format $quote.
Content-Type: text/plain
A comment to this usage note about the behaviour of format $quoteW.
>V6-FORMATS-6917
>Default width for the $QUOTE format is the length of the variable
>
>---------------------------------------------------------------------
>The $QUOTEw. format writes data values enclosed in double quotation
>marks. The format's default width is the length of the variable,
>therefore when specifying the $QUOTE. format without a specified width
>the result will be missing. Use the variable's width plus 2 when using
>the $QUOTE. format.
>
>In SAS 9.1 the default width for the $QUOTEw. format has been changed
>to be the length of the variable + 2.
The usage problem occurs when you try to quote a value without enough
empty space in the character variable to hold also the quote marks.
beware that solution offered for sas9.1....
The problem occurs when you try to $quote a value which contains
embedded quote marks ..........
Then the extra two on output length may not be sufficient
Just in case you have a variable holding text like any of:
"Don't try this at home, kids" said the magician
The picture string is bounded by single(') or double(") quotes
id, name, "last changed", "facility limit", "collateral type"
At some point the capacity to hold the text get fully used. When that is
formatted with the default length for $quote, the result is not
truncated, but blank.
Even with the proposed SAS9.1 behaviour where the default width becomes
2 more than the original variable, the result can become blank because
the $quote format adds not only the bounding quote marks, but also
repeats each internal/embedded quote mark.
"""Don't try this at home, kids"" said the magician"
Instead of 2, probably there is _no_ adequate number to add to the
length of the original, if the output width must be defined this way.
Having had to work-around this problem, a satisfactory solution I have
found at the "put statement stage", is to predefine the format as
$quote32000.
and use no explicit format in the put statement.
Then I'm unlikely to run out of space for these extra quotes.
I don't offer a workaround for a "visible-layer"........ this isn't the
issue for the "human eye" that is for data management.
What's your judgement on the problem/solution ?
--
Peter Crawford
available for contracts