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.
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;
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;
@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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.