07-22-2014 04:59 AM
Does anyone know how to cover character values to numeric values so that I can run analysis? All my data when I imported it was character values on SASUniversity. I have tried different methods and none of which seem to work. Thanks.
07-22-2014 05:46 AM
SanjayAhir is quite correct, input for char to num, put for num to char. However one thing I would add is to check your import. What are you importing, an Excel file, delimited, datalines? Depending on application you can set guessrows larger for Excel, or use a datastep to read in the data in the required format straight away.
07-22-2014 08:46 AM
I Am importing a csv file.
so I would type in the code:
so my my variables I would use the code each time for every variable. Say my variable was called age and my file was called Megandatamerge1.csv I would ente. The following code:
07-22-2014 09:01 AM
Set this on your import then:
attrib var1 var2 format=$20. var3 var4 format=best.;
infile "...\xyz.csv" dlm=',' dsd missover;
input var1 $ var2 $ var3 var4;
No need to convert.
07-22-2014 01:32 PM
This is the code I did and didn't work.
attrib FoodSR CAff format=$20. Sugar Carb format=best.;
infile "datamerge1.csv" dlm=',' dsd missover;
input FoodSR $ CAff $ Sugar Carb;
07-22-2014 01:47 PM
Sorry, you will have to give a bit more info. What didn't work, it didn't import at all? Warnings/Errors, file was created but all text? Maybe post the file itself. Does the numeric fields contain any non-numeric information?
07-22-2014 06:01 AM
what kind of file are you importing or which procedure are you using to import??
I meant to say you are importing excel file, CSV file or any other format and for that you are using import wizard or PROC IMPORT procedure or any other way