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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2824 views
  • 2 likes
  • 4 in conversation