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 (March 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: "Fehd, Ronald J." <rjf2@CDC.GOV>
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. > > Knot! > 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"

<snip>

Hi Ron,

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:

data a; x=1; run;

data _null_; set a; call symput("x",x); run;

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).

proc sql; select x INTO :x from a; quit;

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; 2584 x=1; 2585 y='2'; 2586 run;

2588 data b; 2589 set a; 2590 z=x||y; 2591 run;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 2590:5

2593 proc sql; 2594 select x||y as z 2595 from a; ERROR: Concatenation (||) requires character operands. 2596 quit; NOTE: The SAS System stopped processing this step because of errors.

Kind Regards, --Quentin


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