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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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