BookmarkSubscribeRSS Feed
juniorSAScap
Calcite | Level 5

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?!

FYI:

%MACRO makeds;

%do i=1 %to 5;

filename ref '...&i..xls';

PROC IMPORT out=work.intermediate datafile=ref dbms=xls replace;

sheet="Sheet1";

RUN;

DATA mylib.coating&i;

     set work.intermediate;  --> intermediate dataset has character column when sheet contains some missing values (.), why??

     coating=&i;

RUN;

%end;

%MEND makeds;

Many thanks for your insights!

5 REPLIES 5
art297
Opal | Level 21

use the guessingrows option

juniorSAScap
Calcite | Level 5

Ok, I did, now all five sheets are imported with response column as character datatype...even worse Smiley Happy

Also it says guessingrows is invalid option. XLS are not delimited files, while guessingrows option is restricted to delimited files.

ballardw
Super User

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.

art297
Opal | Level 21

Depending upon how old a version of excel you are using, there is another option:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1007A&L=sas-l&P=R3424&D=1&H=0&O=D&T=1&m=315710

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.

Ksharp
Super User

Did you try to use option

mixed=yes

This will produce character variable if your column is mixed with number and non-number.

Ksharp

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3511 views
  • 1 like
  • 4 in conversation