02-23-2012 09:07 AM
Good Morning All,
I have a large data set that is reading in an excel file that has character and numeric values in the file. The variable names are Var5-Var205 and are charater. I was hoping to write an array-do loop to convert these variables to numeric. I can't seem to figure it out. I've looked for another discussion and can't find anything. If someone knows the solution or has another discussion available, I'd appreciate it.
Have a great day.
02-23-2012 09:23 AM
retain var5-var205 (201*"12");
data want (drop=i in;
set have (rename=(var5-var205=invar5-invar205));
array in(201) $ invar:;
do i=1 to 201;
Of course, if you don't need your variables to be labeled "var", you would get rid of the annoying notes in the output.
02-23-2012 09:32 AM
I tried doing something similar. Here is what I wrote:
format var305-var505 13.2;
array variable(201) var5-var205;
array new(201) var305-var505;
do i =1 to 201;
In multiple rows, I have data like 198,487.33 and it outputs it in the new variable as a period. Same thing happens with code like yours. Thoughts?
02-23-2012 09:38 AM
Can you attach a file that contains a couple of records from your original file? Your code wouldn't work because you: (1) don't indicate that the first array is going to contain character variables and (2) the correct function to use to convert character to numeric would be input, not put.
I would try it again, but using the code i suggested, but use a comma. informat rather than the best12. or whichever one I had suggested. See: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000204404.htm