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.

 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

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