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
Data hello;
Set Bye;
NumKite = input(kite, 8.);
Drop kite;
Rename NumKite = Kite;
run;
Is there a better way rather then the drop and rename?
thank you for your help
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?
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.
Not really.
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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.