10-21-2013 03:54 PM
I am bringing in a table from excel to SAS. I am having trouble with converting one of the columns into a character column. I have a column in excel with some of the cells as dates and some of the cells as text. I would like to import this column as text though. How can I do this?
10-21-2013 04:03 PM
It somewhat depends on how you're importing it (which DBMS you're using), but most of the time the MIXED=YES option is helpful for what you're asking. If not, post your full import code (with filename anonymized if needed) so you can get the best help possible.
10-21-2013 04:11 PM
PROC IMPORT OUT= WORK.IMPRT_EXCEL DATAFILE= 'C:/new.xls' DBMS=EXCELCS REPLACE; PORT=0000; SERVER='01.01.001.01'; SHEET="grp"; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN;
10-21-2013 04:48 PM
I could add three rows with text value at the top of your excel file to force sas treating your date column as text and delete the added row after importing.
10-21-2013 06:38 PM
You could also specify the value "guessingrows=32000". That will make SAS look at the first 32,000 rows of data to guess the type instead of the first 8.
If you can't be guaranteed that the text occurs in the first 32000 rows, then I would suggest not using proc import from an excel file (frankly I suggest this anyways. Excel is just an awful data storage program).