<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How remove spacing text data set on next line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879806#M347576</link>
    <description>&lt;P&gt;So you say you have a VARIABLE.&amp;nbsp; So that must be in a DATASET.&amp;nbsp; And you want to collapse the data from multiple OBSERVATIONS into one observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you know which observations get combined?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It the dataset is TINY then just collapse it into one observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have end=eof;
  length new_var $4000 ;
  retain new_var;
  new_var = catx(' ',new_var,old_var);
  if eof ;
  drop old_var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise you need some variable (or set of variables) then uniquely identify the observations that go together.&amp;nbsp; (And also perhaps some other variable that indicates the ORDER they should have in the new combined string).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have end=eof;
  by group order ;
  length new_var $4000 ;
  retain new_var;
  if first.group then new_var=' ';
  new_var = catx(' ',new_var,old_var);
  if last.group ;
  drop old_var order;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Jun 2023 17:10:56 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-06-08T17:10:56Z</dc:date>
    <item>
      <title>How remove spacing text data set on next line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879803#M347574</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two variables which contain text data. Some of the text is set on multiple lines, but I would like the text to be on one line with one space between each word. Example of current format:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Well&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Baby&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Example of desired format:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Well Baby&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried two different things. First Try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data final;
	set data;
	location=tranwrd(location,'Well
Baby','Well Baby');
	quality=tranwrd(quality,'Needs
Repeat
Test','Needs Repeat Test');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I export the above output to excel, the next line spacing is still there. I used ods excel and proc report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second Try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data final;
	set data;
	location_compbl = compbl(location);
	quality_compbl = compbl(quality);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I export to excel, the next line spacing goes away when I choose 'wrap text' but then there are no spacing between the words.&amp;nbsp;I used ods excel and proc report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your suggestions!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879803#M347574</guid>
      <dc:creator>ark123</dc:creator>
      <dc:date>2023-06-08T16:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: How remove spacing text data set on next line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879806#M347576</link>
      <description>&lt;P&gt;So you say you have a VARIABLE.&amp;nbsp; So that must be in a DATASET.&amp;nbsp; And you want to collapse the data from multiple OBSERVATIONS into one observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you know which observations get combined?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It the dataset is TINY then just collapse it into one observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have end=eof;
  length new_var $4000 ;
  retain new_var;
  new_var = catx(' ',new_var,old_var);
  if eof ;
  drop old_var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise you need some variable (or set of variables) then uniquely identify the observations that go together.&amp;nbsp; (And also perhaps some other variable that indicates the ORDER they should have in the new combined string).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have end=eof;
  by group order ;
  length new_var $4000 ;
  retain new_var;
  if first.group then new_var=' ';
  new_var = catx(' ',new_var,old_var);
  if last.group ;
  drop old_var order;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jun 2023 17:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879806#M347576</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-08T17:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: How remove spacing text data set on next line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879817#M347578</link>
      <description>&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion. Unfortunately, that did not work for me - it removed all but one observation in my dataset.&amp;nbsp;&lt;SPAN&gt;To clarify, I have a dataset with 5,000 records and 50 variables. One of these variables is location ('well baby' 'nicu' and 'other'). Another variable is quality ('Acceptable' and 'Needs Repeat Test'). When I was exporting to excel, the words were on individual lines:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Well&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Baby&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Well Baby&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Needs&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Repeat&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Test&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Needs Repeat Test&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In attempting your suggestion and viewing the output in excel, I realized the solution is to export the file to excel differently. When I export using proc export excel, the words are formatted on one line with proper spacing between each word. Thanks for your input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solution: use proc export rather than ods excel file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 18:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879817#M347578</guid>
      <dc:creator>ark123</dc:creator>
      <dc:date>2023-06-08T18:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: How remove spacing text data set on next line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879818#M347579</link>
      <description>&lt;P&gt;So your problem was with the EXCEL file and NOT with either the SAS dataset or a text file with LINES in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead what ever method you used to produce a REPORT into an XLSX wrapped the lines.&amp;nbsp; ODS EXCEL will actually insert line breaks into the long strings to make the report look better, unless you tell it not to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use the XLSX libname engine to copy data to an XLSX file.&lt;/P&gt;
&lt;P&gt;This code will create a sheet named mydata in the XLSX file named myfile.xlsx from a work dataset named mydata.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname out xlsx 'myfile.xlsx';
data out.mydata;
  set mydata;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 19:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-remove-spacing-text-data-set-on-next-line/m-p/879818#M347579</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-08T19:01:14Z</dc:date>
    </item>
  </channel>
</rss>

