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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 1166 views
  • 0 likes
  • 4 in conversation