BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mrinal
Calcite | Level 5

Hi All,

I would request your help with the following SAS query, I am able to import all variable values from the .xls file except one (Interest_outstanding) using proc import statement.


My code is..

libname SAS "C:\Users\mrinal\Desktop\test";

proc import datafile = "C:\Users\mrinal\Desktop\test\Badahar.xls"  out=SAS.g1 ;run;

Request your help on this. Attached is the .xls file.

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

This worked for me .

proc import datafile = "C:\temp\Badahar.xls" dbms=xls replace out=x ;

run;

proc import datafile = "C:\temp\Badahar.xls" dbms=excel replace out=x ;

mixed=yes;

run;

Xia Keshan

View solution in original post

5 REPLIES 5
karabas
Calcite | Level 5

SAS analyzed first 5 rows to determine variable format. Your 1st 5 values are blank and SAS assign to this variable Character.

Enter 0 (zero)  for Interest_outstanding in first row and save file. Now you will be able to import it correctly.

Mrinal
Calcite | Level 5

Well, if i assume that the following things imply:

blank= data missing for the variable

0= zero value  for that particular observation and

x = any other number.

So putting a zero in the first row would imply that the value will be taken as zero where as actually, the data might be missing. Any other way to go about this?

ballardw
Super User

Look in the online help for Microsoft Excel Workbook Files on how to set the WINDOWS registry to look at more rows before assigning a column type. The type is basically controlled by the MS application, NOT SAS.

Or export the data to CSV and use a larger value for guessing rows on import.

The whole direct Excel to SAS import using proc import is fairly limited for your control so there are oddities that can occur.

Ksharp
Super User

This worked for me .

proc import datafile = "C:\temp\Badahar.xls" dbms=xls replace out=x ;

run;

proc import datafile = "C:\temp\Badahar.xls" dbms=excel replace out=x ;

mixed=yes;

run;

Xia Keshan

Mrinal
Calcite | Level 5

Thank you.

Yes, both the codes are working for me. Smiley Happy

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1519 views
  • 0 likes
  • 4 in conversation