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

Hello,

I'm struggling with importing multiple Excel Files into SAS onDemand for Academics.

I'm using the Robintrack dataset and havelaready unpacked it on my PC. Now I have 8597 Excel files in my PC folder, which are all named according to the respective stock.

Can someone help me to write an Macro to import all Excel files into one SAS table with an additional Variable which has the stockname in it?
To import one file is not a problem but I'm not able to import all files at once in a macro, too save them all in one SAS table and to give assigne them a new variable which has the corresponding stock name.

 

Thanks a lot!!!

student12345678_1-1617793269930.png

 

 

student12345678_0-1617793222382.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You can use the upload functionality of SAS Studio to upload the files in batches (I managed A to F in one swoop, but it takes TIME!), after which you can run a single data step to read the files:

data robin;
length fname $200 listing $4;
infile '$HOME/robin/*.csv' filename=fname dlm="," dsd;
input@;
if index(_infile_,"timestamp") = 0;
input timestamp :e8601dt19. listed;
format timestamp e8601dt19.;
listing = scan(scan(fname,-1,"/"),1,".");
run;

I put all the csv files in a folder called robin located directly in my Home on SAS ODA.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

You can use the upload functionality of SAS Studio to upload the files in batches (I managed A to F in one swoop, but it takes TIME!), after which you can run a single data step to read the files:

data robin;
length fname $200 listing $4;
infile '$HOME/robin/*.csv' filename=fname dlm="," dsd;
input@;
if index(_infile_,"timestamp") = 0;
input timestamp :e8601dt19. listed;
format timestamp e8601dt19.;
listing = scan(scan(fname,-1,"/"),1,".");
run;

I put all the csv files in a folder called robin located directly in my Home on SAS ODA.

andreas_lds
Jade | Level 19

Was already on the way to lose consciousness, but then i realized that you don't have excel-files, but csv-files. Do yourself a favor and switch the default application used to open csv-files to a text-editor, that way you will see what's really in the files and not what Excel things you should see.

Tom
Super User Tom
Super User

You can also tell Windows that you want it to show you the real filenames instead of stripping off the extension.

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 1174 views
  • 3 likes
  • 4 in conversation