Hi, I have a dataset that contains multiple records. I need to write it out to a flat file in such a way that all records are written in first record. (same row as header). Below is the code I wrote. But, my job is truncating the file and not outputting all records as I need.
filename credit "/user/ccc/xx/LTR.txt";
data _null_;
set test;
file credit dlm="|" dsd lrecl=60000;
if _n_=1 then do;
put @1'var1|var2|var3|var4|var5|var6|var7'
var1 var2 var3 var4 var5 var6 var7;
end;
run;
NOTE: 1 record was written to the file CREDIT.
The minimum record length was 90.
The maximum record length was 90.
NOTE: There were 7 observations read from the data set WORK.TEST.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.00 seconds
system cpu time 0.01 seconds
Memory 1075k
OS Memory 13352k
Timestamp 1/11/2016 10:41:44 PM
Page Faults 0
Page Reclaims 548
Page Swaps 0
Voluntary Context Switches 19
Try something like :
filename credit "&sasforum.\datasets\credit.txt";
data _null_;
file credit lrecl=60000;
put 'name|sex|age|height|weight|' @;
do while(not done);
set sashelp.class end=done;
put (name sex age height weight) (+(-1)"|") @;
end;
stop;
run;
filename x '/folders/myfolders/x.txt' recfm=n;
proc export data=sashelp.class outfile=x dbms=dlm replace;
delimiter='|';
run;
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.
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.