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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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