SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2584 views
  • 2 likes
  • 3 in conversation