|
"CHRISTENSEN,KEVIN W" <chriske2@UFL.EDU> replied:
> I ended up figuring a way around it...just multiply everything by
> 1. It only works if the characters can be interpreted as numbers.
> And it will likely convert any missing values to zeros
> (thankfully I didn't have any missing values). I'll probably try
> it your way too so I can learn a few things. The code I used is
> below, for posterity's sake.
>
> data wbdata.pop4;
> set wbdata.pop3;
> array pop (43) _1960--_2002;
> do i = 1 to 43;
> pop(i) = pop(i)*1;
> end;
> run;
This will cause an implicit character-to numeric conversion and back,
since SAS will not change your variables from character to numeric.
You have to convert and assign that value to a numeric variable. I
think I should also point out that:
[1] This will NOT convert missing values to zeroes. Just try it.
It can convert missing values listed as a blank into character strings
that look like a period. Which isn't what you wanted above.
[2] If some of your _nnnn variables are character (due to the way you
read them in) and some are numeric, then your array statement will bomb
out. Your arrays needs to be all numeric or all character.
[3] In some environments, an 'implicit character to numeric conversion'
note is considered a sign of a problem with the program. People who
have
written log-checking programs have often included that 'NOTE' as
something
to be concerned about. You will know better than any of us whether
someone
may be looking over your shoulder because of that log message.
[4] The previous suggestions have all been really good ideas. You
really ought to read in your flat file and make sure your numbers are
properly processed, rather than having to patch things up after the
fact. And I do thing that the use of INPUT() is better than the
multiply-
by-one technique above, for several reasons, one of which is clarity of
the code.
HTH,
David
--
David Cassell, CSC
Cassell.David@epa.gov
Senior computing specialist
mathematical statistician
|