06-23-2017 02:09 PM - edited 06-23-2017 03:02 PM
I can't covert all of my data into numeric in SAS version 9. I cleaned all my data and made the character values numerical manually and now I'm trying to get the proc contents to read it as numerical so I can perform statistical tests. This is the code I have been using
I used proc print to check that my data was correct. NEWLOG2 refers to the new variable that is numeric and LOG2 is the original edited variable that now has all numerical values. 1.59 was original included text but won't covert over numerically in the new variable. PLEASE HELP!!!!
06-23-2017 03:10 PM
Redcap can generate a CSV file instead - if the file is in the same format everytime and you're doing this often I'd strongly suggest fixing the import step instead of manually recoding things.
06-23-2017 05:32 PM
Did you get errors from the INPUT() function for the lines that generated missing values?
Either your values are right aligned so that the first 5 characters do not have any value or they have some "invisible" characters that are causing the text to not look like numbers.
First, use 32. or even better COMMA32. as your INFORMAT. (Note BEST is a FORMAT and not an INFORMAT).
Second remove the spaces and/or non digits from the string.
data want ; infile cards truncover ; input str $char50. ; if _n_=1 then str='A0'x||str; if _n_=2 then str=strip(str)||'0D'x; num1 = input(str,??5.); num2 = input(compress(str,'($,ED.)','kd'),??comma32.); put num1= best9. @15 num2=best9. @30 str=:$quote.; cards; 3456 4567 456.123 5677 1.234E3 (123,345) ;
num1=. num2=3456 str=" 3456" num1=. num2=4567 str="4567 " num1=456.1 num2=456.123 str="456.123" num1=. num2=5677 str=" 5677" num1=1.234 num2=1234 str="1.234E3" num1=. num2=-123345 str="(123,345)"