Hi,
My work table has 10 columns which i am trying to export this into .txt file using proc export using "|" delimiter.
Ideally the txt file must contain 9 pipe ("|") symbols separating the 10 columns but here since the last 2 columns has null values in the input data , it has only 8 pipe ("|") symbols and the last column is getting truncated.
for Example ;
Proc export data = a.txt
outfile= b.txt
dbms=dlm replace;
delimiter="|";
putnames=NO;
RUN;
Any help would be much appreciated if anything needed to be included in the proc export option
which would solve my issue.
Can you share an reproducible example?
FYI - There is no need to use PROC EXPORT to produce a delimited file, especially one without a header row. A simple PUT statement will do the job.
data _null_;
set mylib.myds ;
file 'myfile.txt' dsd dlm='|';
put (_all_) (+0);
run;
Thanks @Tom for the simple and elegant example.
@laxmanpai wrote:
Hi,
My work table has 10 columns which i am trying to export this into .txt file using proc export using "|" delimiter.
Ideally the txt file must contain 9 pipe ("|") symbols separating the 10 columns but here since the last 2 columns has null values in the input data , it has only 8 pipe ("|") symbols and the last column is getting truncated.
This does not happen using SAS 9.4m5:
data class;
set sashelp.class;
length Empty1 8 Empty2 $ 10;
call missing(of Empty:);
run;
proc export data=work.class
file= "class_pipe.txt"
dbms=dlm
replace;
delimiter='|';
putnames=no;
run;
Alfred|M|14|69|112.5|| Alice|F|13|56.5|84|| Barbara|F|13|65.3|98|| Carol|F|14|62.8|102.5|| Henry|M|14|63.5|102.5|| James|M|12|57.3|83|| Jane|F|12|59.8|84.5|| Janet|F|15|62.5|112.5|| Jeffrey|M|13|62.5|84|| John|M|12|59|99.5|| Joyce|F|11|51.3|50.5|| Judy|F|14|64.3|90|| Louise|F|12|56.3|77|| Mary|F|15|66.5|112|| Philip|M|16|72|150|| Robert|M|12|64.8|128|| Ronald|M|15|67|133|| Thomas|M|11|57.5|85|| William|M|15|66.5|112||
Show us the LOG from when you run the code. Copy the entire code for the step involved plus all notes and messages from the LOG. Paste into a text box opened on this forum with the </> icon to preserve formatting.
Also, which program did you use to open the text file and examine the contents?
You say "it has only 8 pipe ("|") symbols and the last column is getting truncated.". Is this truncation on the the line with only 8 pipe symbols or on other lines? I ask because you say the 8 pipes occurs where the last two columns are "null" values. So how would tell that a missing last column is truncated.
If any of your variables contain a linefeed and/or carriage return character you might be seeing the result from the content of your data. Does it appear that a line of data might only have one or two | symbols with very short data?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.