BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
val_nikolajevs
Obsidian | Level 7

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
JosvanderVelden
SAS Super FREQ
Because you have spaces in the row sas 'helps' by adding the quotes when you use the dlm option. Do you get the desired result if you remove the dlm option? If not try to use dlm=','

Best regards, Jos

View solution in original post

4 REPLIES 4
JosvanderVelden
SAS Super FREQ
Because you have spaces in the row sas 'helps' by adding the quotes when you use the dlm option. Do you get the desired result if you remove the dlm option? If not try to use dlm=','

Best regards, Jos
val_nikolajevs
Obsidian | Level 7

Thank you very much. That worked. I got desired results.

Tom
Super User Tom
Super User

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;

 

val_nikolajevs
Obsidian | Level 7
Thank you.
Yes this a single variable
Your solution works too. delimiter was causing the problem.
Thank you,
Val

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 4 replies
  • 2015 views
  • 0 likes
  • 3 in conversation