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

Hi all,

I got a problem in importing excel file (.xlsx);

I have tried with porc import

here's the code:

 

proc import datafile = " D:\myfolder\sample.xlsx" dbms = excel out = output;

sheet = sheet1;

run;

 

by running this code sheet has been imported, but problem is, actually my sheet contains 12 variables, but SAS imported 24 columns in which 12 were empty coulmns and also after running this code I have'nt found any infile/input code in log; so, what might be the reason for this? 

I want infile/input code to import excel file, please can someone write infile code to improt excel file !

 

Regards and Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Excel keeps track of all cells that have been manipulated at least once, and computes a virtual "sheet size" from that.

Delete all empty columns and rows up to where your import "ended", before you try the import again. That deletion will remove the "used" information from the cells.

 

Alternatively, save to csv from Excel and use a custom data step to only read the columns you want.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Excel keeps track of all cells that have been manipulated at least once, and computes a virtual "sheet size" from that.

Delete all empty columns and rows up to where your import "ended", before you try the import again. That deletion will remove the "used" information from the cells.

 

Alternatively, save to csv from Excel and use a custom data step to only read the columns you want.

Tom
Super User Tom
Super User

If SAS created 24 variables then the XLSX sheet had 24 "used" columns.  Best fix for that it is to update the XLSX file.  But it is also easy to DROP the variables from your SAS dataset.

 

Not sure what you are talking about the LOG, but you will not see an INFILE statement used to read a structured binary file like an XLSX file like you would for reading a simple delimited text file like a CSV file.

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
  • 2 replies
  • 1971 views
  • 2 likes
  • 3 in conversation