07-28-2015 02:50 PM
I have the following data set and I wonder if someone can tell me the Code to change the ID column from Character to Numeric so that I can do analysis. My problem is I have some value under ID column that are combination of character and numeric (eg. V13), therefore consider the whole column as text.
The analysis code for my analysis is:
where ID between 12 and 24;
07-28-2015 02:57 PM
create a new variable using the input function.
some examples here: SAS(R) 9.3 Functions and CALL Routines: Reference
07-28-2015 03:56 PM
where ( input( ID,best6.)) between 12 and 24;
though if you expect to get V13 in that result you'll need to do more coding to strip off the character bits before conversion.
07-28-2015 03:59 PM
Do you need to keep the 13 after the V? If so use the num_id line. If you want to drop anything that has a character use the new_id line. Run this and you'll see what I mean:
infile cards dsd;
input Name$ ID$;
new_id = input(id,8.);
num_id = input(compress(id,'a','a'),8.);