04-23-2014 05:33 PM
I recently realized that when I ran strip on a numeric field (on accident) it actually converted it to character for me, and SAS issued the warning "numeric values have been converted to character at lines :::".
My general question becomes, if you are trying to simply convert variables to characters, wouldn't it just be easier to define them as newvar=strip(oldvar), so you can avoid the informat mess used with the put statement?
I am curious as to the ups / downs of this method and wasn't able to really find any documentation on why put is the 'go to' for this task... And any all comments will be helpful!
04-23-2014 05:48 PM
Isn't it a NOTE: not a WARNING:? In PHARMA we like a clean log and that's a dirty note. :smileysilly:
With the automatic conversion there is only one FORMAT choice, with PUT you have options. You might also look at VVALUE that is conversion with associated FORMAT applied.
04-23-2014 05:55 PM
I'm sorry it is a NOTE: thank you for pointing that out. And I do understand the idea of the dirty note vs clean log, I guess my point is what if you run into the following circumstance (I just did).
You read in data from a database that does not have an associated format (its numeric length 8).
If I wanted to use a put statement, I can't use a proc contents and grab the informat length (or informat itself) because they would not exist.
Is there a "general" format you can hard-code into your put statements that will work on all numeric data types? I've actually been using Best32 in my macro strings but am not sure if that will ever cause problems (i don't believe it will... but what I don't know about SAS could fill the congressional library).
If I understood your statement above about Vvalue, then I think VValue solves the problem when I want the associated format with the column (and thanks a TON for that, that's actually super helpful as I was not aware of this function). My question I think makes the most sense with an example.
infile datalines delimiter=',';
format balance dollar32.2;
input balance $ ;
In the above code, is it acceptable for me to use best32 (given I don't want the dollar signs in my new character field?).
As always _null_ thank you very much for helping me with questions i'm sure are overly easy.