BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Hi 

Good Evening 

How to import multiple csv files as a single dataset 

1 REPLY 1
Tom
Super User Tom
Super User

@BrahmanandaRao wrote:

Hi 

Good Evening 

How to import multiple csv files as a single dataset 


Don't "import" them.  Instead just read them.  

I will assume they all have the same structure, otherwise why are you putting them into a single dataset?

data want;
   length fname filename $256 ;
   input '/mydir/*.csv' filename=fname dsd truncover ;
   input @;
   if fname ne lag(fname) then input ;
   input  .... ;
   filename=fname;
run;

Just replace the 'input ....' statement with the code to read your variables.  So you might want to first use LENGTH statement to define the variable before the INPUT statement.  Also you might want to add FORMAT and/or LABEL statements.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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