Hello Everyone,
I need to generate a text file from the following rows without " sign at the beginning and the end of each row.
data in dat_out1:
Row1 (used multiple lines with '0d'x,'0a'x (CRLF) line separator at the end of each line:
000011111 0000022222 033333 NNNNN
00001111a 000002222a 03333a NNNNN
00001111b 000002222b 03333b NNNNN
Row2:
000011111 0000022222 033333 NNNNN
00001111a 000002222a 03333a NNNNN
00001111b 000002222b 03333b NNNNN
Using the following code:
data _null_;
file "C:\test.txt" dsd dlm='' mod;
set dat_out1;
put (_all_) (+(-1));
run;
I got those results when see this in note pad:
"000011111 0000022222 033333 NNNNN
00001111a 000002222a 03333a NNNNN
00001111b 000002222b 03333b NNNNN"
"100011111 1000022222 133333 NNNNN
10001111a 100002222a 13333a NNNNN
10001111b 100002222b 13333b NNNNN"
And I need to get the following -- no separators, no quote signs only CRLF at the end of each line:
000011111 0000022222 033333 NNNNN
00001111a 000002222a 03333a NNNNN
00001111b 000002222b 03333b NNNNN
100011111 1000022222 133333 NNNNN
10001111a 100002222a 13333a NNNNN
10001111b 100002222b 13333b NNNNN
Is there an option to work directly with the txt file and do find/replace-delete " ?
Or export parameters should be modified?
Thank you for your help.
Val
Thank you very much. That worked. I got desired results.
I don't understand what you dataset looks like. Do you just have the one variable?
The quotes are because the value being written includes the delimiter and you asked it to use the DSD option. It does not make any sense to include the DSD option. You are not writing delimited data. It might look delimited to you, but you have a already inserted the delimiters into the data and just want SAS to write the strings.
So if your string with the LF's is in a variable named VAR1 in the dataset name DAT_OUT1 then this code would append the values to the end of the file C:\test.txt. Note that it will write its own end of line characters after each observation.
data _null_;
file "C:\test.txt" mod;
set dat_out1;
put var1 ;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.