Date: Fri, 22 Mar 2002 14:33:05 -0500
Reply-To: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Subject: Re: Proc Sql and INTO macro variable Value
Content-Type: text/plain; charset="iso-8859-1"
Ron Fehd wrote:
> > From: Quentin McMullen [mailto:QuentinMcMullen@WESTAT.COM]
> > Dennis Diskin (and many others) have already explained:
> > > The default format for all numeric variables in SAS is BEST8.
> > > When you tell SQL to put something INTO a macro variable, it
> > > must convert it to a character string
> > Given that, I think I'd be happier to see SAS put a NOTE: to
> > the log when it
> > does the automatic numeric to character conversion for INTO,
> > as done with automatic conversions in a data step.
> It's your incorrect assumption that the macro language
> is a number-crunching language, just like SAS.
> It is a string-processing language.
> No macro variable is a number,
> even despite your natural-language parsing:
> "has digits, decimals, no leading zeros, must be a number"
I do understand that the macro language is for string processing, and that
as much as the resolved string from a macro variable may look like a
"number", it's always just a string.
My point is that when you code:
You get a nice NOTE: saying that you have fed a numeric variable into call
symput, and because it was expecting a character variable (in order to shove
the string into a symbol table), call symput will go ahead and convert the
numeric value of x into a character value. As we saw in the original post,
the result of such implicit conversions with default (in)formats can be
surprising to some. Thus many folks view this note as an error message
warning that they have forgotten a (in)put statement.
Similarly, when I code the below my understanding is that SAS is doing the
same thing (i.e. implicit conversion of the numeric value from x into a
character value, then sending that string into the symbol table).
select x INTO :x
I'd rather have SAS give me the same NOTE: from SQL INTO: as it does from
symput in a data step. In general, SQL seems *less* willing to do automatic
conversions than the data step, which I like:
2583 data a;
2588 data b;
2589 set a;
NOTE: Numeric values have been converted to character values at the places
2593 proc sql;
2594 select x||y as z
2595 from a;
ERROR: Concatenation (||) requires character operands.
NOTE: The SAS System stopped processing this step because of errors.