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

Hey,

 

I am looking to export multiple data sets into one DLM/CSV file, column names are not the same and formats are different. So far I have:

 

PROC EXPORT DATA=TEMP1

OUTFILE='C:\myfile'

DBMS=DLM REPLACE;

PUTNAMES=NO;

DELIMITER='|';

RUN;

 

I still need data files TEMP2 and TEMP3 added. Any help would be appreciated.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Use MOD option .





data _null_;
 set sashelp.class;
 file '/folders/myfolders/x.txt' mod delimiter='|' dsd;
 put (_all_) (:);
run;

data _null_;
 set sashelp.cars;
 file '/folders/myfolders/x.txt' mod delimiter='|' dsd;
 put (_all_) (:);
run;


View solution in original post

3 REPLIES 3
Reeza
Super User

You need to use a data step instead. 

 

It it also seems like a bad idea, I would hate to receive a file like that. 

Ksharp
Super User
Use MOD option .





data _null_;
 set sashelp.class;
 file '/folders/myfolders/x.txt' mod delimiter='|' dsd;
 put (_all_) (:);
run;

data _null_;
 set sashelp.cars;
 file '/folders/myfolders/x.txt' mod delimiter='|' dsd;
 put (_all_) (:);
run;


RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Thats fundamentally against the purpose of a CSV file.  A CSV file is defined as a text file, with one row or fewer of column headers, with subsequent records detailing the data of those columns, delimited by a comma.  To that effeect if I was to recieve your described file I would reject it, and I would be surprised if anyone willingly accepts it as such.  Export each data strcuture to its own file - you would need to document this in any data transfer agreement document anyways.

 

There are other options out there if you need to ship data as flat file but with structure, JSON and XML can both be used to contain multiple different structures within one file.  The question you have to ask is wether its worth the effort, most of the time just create one CSV file per dataset is simplest.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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