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

Hello.

I have dataset with one column that contains a lot of records.

For example the first 3:

abc

 def

    ghi

How can i merge it into 1 record? -

abc def ghi

The important thing also is that all blanks must be saved.

 

 

 

  

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

That seems silly.  Just leave the HTML text as is and then when writing it to an actual HTML file just don't instead any line breaks.

So if you have a dataset named HAVE with a variable named TEXT that is defined to hold 100 bytes and you want to use it to create a one line HTML file named myfile.html use something like:

data _null_;
  file 'myfile.html' recfm=n ;
  set have;
  put text $char100.;
run;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Which spaces need to be preserved?  Just the leading spaces?

data want;
  set have end=eof;
  length new_var $300 ;
  new_var = trimn(new_var) || var;
  if eof;
run;

Or the trailing spaces that are added to pad the string value to the full length of the variable?

data want;
  set have end=eof;
   length new_var $300 ;
   substr(new_var,(_n_-1)*vlength(var)+1,vlength(var))=var;
  if eof;
run;

Do you really only want one observation?  Why ? Or is there some grouping variable?

data want;
  set have end=eof;
  by id;
  length new_var $300 ;
  if first.id then new_var=' ';
  new_var = trimn(new_var) || var;
  if last.id;
run;
A1ex777
Fluorite | Level 6

@Tom Tom thanks a lot for quick answer.
Yes i need both type of spaces.

There's no grouping variable. I just have dataset with column that contains separate records with html text. So i need to store it in one record.

Tom
Super User Tom
Super User

That seems silly.  Just leave the HTML text as is and then when writing it to an actual HTML file just don't instead any line breaks.

So if you have a dataset named HAVE with a variable named TEXT that is defined to hold 100 bytes and you want to use it to create a one line HTML file named myfile.html use something like:

data _null_;
  file 'myfile.html' recfm=n ;
  set have;
  put text $char100.;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1225 views
  • 3 likes
  • 2 in conversation