04-06-2018 09:11 PM
Just wondering if there is a more efficient way to charge a var from char to num. Often I import dataset and find out in a merge that the varible isn’t the same type. This is how I do it
NumKite = input(kite, 8.);
Rename NumKite = Kite;
Is there a better way rather then the drop and rename?
thank you for your help
04-06-2018 09:36 PM
By far the best approach is to import it into the correct data type to begin with and not convert it at all. I bet you are importing from Excel which has a mind of its own when deciding in what format it will deliver data. One way to enforce correct data types is to import from CSV files and not Excel. Is this a possibility for you?
04-07-2018 01:21 PM
04-08-2018 05:04 PM
You don't have to define all your variables to import a CSV file. You can use PROC IMPORT with DBMS = CSV similar to Excel. Using the GUESSINGROWS option as well will probably get you a better result than with Excel.
04-07-2018 05:15 PM
If you are doing your "merge" using SQL then you can just do the conversion there.
proc sql ; create table want as select * from a , b where a.kite = input(b.kite,32.) ; quit;