Hi,
I'm trying to create a .txt file using proc export from sas dataset using pipe delimiter. But in data, there is a pipe value in the field causing us the major problem.
Is there a way can we introduce a escape char or single / doubles quotes in the field where we get the pipe value. Please advise.
Thanks
@helannivas88 wrote:
Hi,
I'm trying to create a .txt file using proc export from sas dataset using pipe delimiter. But in data, there is a pipe value in the field causing us the major problem.
Is there a way can we introduce a escape char or single / doubles quotes in the field where we get the pipe value. Please advise.
Thanks
Please describe the "major problem" you are having. Any value that contains a delimiter character that is exported with Proc Export will have the entire string enclosed in quotes.
If you run this code (modified to export to a location on your system)
data pipe; x='string with| in the middle'; y='String without'; run; proc export data=pipe outfile="<path>\pipe.txt" dbms=dlm replace; delimiter='|'; run;
The resulting file will look like:
x|y "string with| in the middle"|String without
So, we kind of need to know the exact problem you have with using the file.
This code already puts the data in quotes
data _new;
informat have $32.;
input have $ var2;
want=compress(compress(have,' +/*-%','A'));
cards;
BIOL1012|8DCWc	10128
ANT102	102
PSY125	125
SOC101	101
SPAN2330	2330
HIST1500	1500
BCS-205	205
BCS-132	132
;;;
run;
proc export data=_new outfile='test.csv'
dbms=dlm replace ;
delimiter='|' ;
run;It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.
