01-03-2012 09:51 AM
Hi, could anyone provide me with understanding of the following:
Situation: I am importing with PROC IMPORT experimental response data stored in five Excel sheets (response data for five different coating types). In each sheet, the response column has 300 obs, all numeric values except for a (very) few missing values denoted in the sheet by a dot (.). Only two of the five sheets have missing responses.
Problem: For the two sheets that contain missing values, SAS imports the response column as character datatype.
I understand that the datatype for the column is determined based on the first 8 rows. The missing values are way below these first rows, so 100% sure SAS should import this column as numeric datatype. Why doesn't it?! How to remedy?!
%do i=1 %to 5;
filename ref '...&i..xls';
PROC IMPORT out=work.intermediate datafile=ref dbms=xls replace;
set work.intermediate; --> intermediate dataset has character column when sheet contains some missing values (.), why??
Many thanks for your insights!
01-03-2012 10:03 AM
Ok, I did, now all five sheets are imported with response column as character datatype...even worse
Also it says guessingrows is invalid option. XLS are not delimited files, while guessingrows option is restricted to delimited files.
01-03-2012 10:10 AM
I believe the behavior you are seeing is because of the EXCEL data engine not SAS.
I know of two work arounds 1) don't let the Excel sheet get populated with the (.)
2)save each sheet as CSV and then the problem either goes away or the guessingrows will work.
01-03-2012 10:53 AM
Depending upon how old a version of excel you are using, there is another option:
It was for the older excel versions and I haven't seen an update for 2007+ if you happen to be using a newer version.