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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.