BookmarkSubscribeRSS Feed
nayab_shaik
Calcite | Level 5

Hi Team,

 

i need one help

 

How to export multiple files in sas by using file name statement

 

Advance Thanks 

 

 

 

 

 

 

6 REPLIES 6
Ivan555
Quartz | Level 8

Hello!

 

In which format do you want to export data from SAS? In .xlsx, in .sas7bdat, in .csv, others?

nayab_shaik
Calcite | Level 5

in text format

Ivan555
Quartz | Level 8

Have a look, thats not what you need?

proc sql; create table t1 as select * from sashelp.air; quit;

%let path ="/home/sasserver/sasuser/files/test.txt"; /*input your path*/
proc export data=t1 outfile=&path. label dmbs=tab replace; putnames=yes; %run;

 

If you need other formats it is also possible.

nayab_shaik
Calcite | Level 5

by using data step file name statment

Ksharp
Super User
proc sort data=sashelp.class out=have;
by sex;
run;


data _null_;
 set have;
 fvar=cats('c:\temp\',sex,'.txt');
 file dummy filevar=fvar dsd mod;
 put (_all_) (:);
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register 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
  • 6 replies
  • 1499 views
  • 0 likes
  • 4 in conversation