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

Hi Everyone,

I am trying to read a few hundred excel files (.xlsx) into SAS. Below is the code that I have put together from various sources (mostly UCLA). Each excel file has the same column names, but the length of the strings in the columns change from one excel file to another. The challenge is that each excel file has two sheets, and data is located in "Data Sheet". I have been trying to figure out where to put a statement like "sheet="Data Sheet" in the code, but I could not figure out where. (Note: I also have a macro code that imports all this data using PROC IMPORT, but truncation is such a big problem that I am now using the code below). I look forward to hearing your suggestions.

Thanks!

%let dirname = _____________;

      filename DIRLIST pipe "dir /B &dirname\*.xlsx";

     

      data dirlist ;

length fname $256;

infile dirlist length=reclen ;

input fname $varying256. reclen ;

      run;

      proc print data = dirlist;

run;

data all_cint (drop=fname);

  length myfilename $50;

  set dirlist;

  filepath = "&dirname\"||fname;

  infile dummy filevar = filepath length=reclen end=done missover firstobs=2 dlm=',' dsd lrecl=32767 ;

  do while(not done);

    myfilename = filepath;

[followed by input names]

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Have you looked into DBSASTYPE option with a libname method of importing?

View solution in original post

1 REPLY 1
Reeza
Super User

Have you looked into DBSASTYPE option with a libname method of importing?

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!

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
  • 1 reply
  • 4583 views
  • 0 likes
  • 2 in conversation