Date: Fri, 17 May 2002 13:32:54 -0400
Reply-To: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Subject: Re: determining variable type
Content-Type: text/plain; charset="iso-8859-1"
Peter Crawford wrote:
> Hi Quentin McMullen [SMTP:QuentinMcMullen@WESTAT.COM]
> If you can make a correct length statement, then you
> can use the correct data type in the compare !
> Otherwise you just move the problem to another
> place in your code.
> I do not understand in what circumstances you would be
> able to define the requirements for a compare, but not
> know the data type !
> Even if it is a numeric string......
> Unless you are happy with automatic data conversion.
> If you want to compare a var. of unknown data type with
> missing (blank or . ) then v8 offers the missing() function
> > do until ( missing(var1) );
> which would compile and execute correctly
> ====== but only if that is what you need !
I think you miss my point (or I miss yours). I have dataset work.A with a
input Var1 $1;
Knowing that Var1 is character, I mistakenly thought that I would be ok if I
used the correct type in the compare.
do until (upcase(var1)='A');
But my point is the above doesn't work. In this case using the correct type
in the compare is not enough. SAS makes var1 numeric, despite evidence to
the contrary. While I "know" var1 to be character, and make every attempt
to treat it above like a proper character variable, SAS still makes it
numeric. So to convince SAS that it is character, I must add a statement at
the top of the step which will determine the type (length statement, or
Bruce's if 0 then set a, etc.).