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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 753 views
  • 3 likes
  • 2 in conversation