<?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: Need to insert line break in Excel using PROC EXPORT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/951771#M372025</link>
    <description>Many tnks for your kindly help I try immediately. Have a nice day. Tecla</description>
    <pubDate>Mon, 25 Nov 2024 10:31:45 GMT</pubDate>
    <dc:creator>Tecla1</dc:creator>
    <dc:date>2024-11-25T10:31:45Z</dc:date>
    <item>
      <title>Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909531#M358724</link>
      <description>&lt;P&gt;I am creating an Excel workbook and for a specific cell within a worksheet, I need to insert line breaks/wrapping to make it more readable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, my variable MHDEETS has this value and looks like this within Excel&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;01. Seasonal allergy /Ongoing 02. Appendicectomy YYYY/YYYY 03. Hypoxia YYYY-MM/Ongoing&amp;nbsp; 04. Hypoxia YYYY-MM-DD/YYYY-MM-DD 05. Right ventricular failure YYYY-MM-DD/YYYY-MM-DD 06. Atrial flutter YYYY-MM-DD/YYYY-MM-DD&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, I'd like for it to appear like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;01. Seasonal allergy /Ongoing &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;02. Appendicectomy YYYY/YYYY &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;03. Hypoxia YYYY-MM/Ongoing&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;04. Hypoxia YYYY-MM-DD/YYYY-MM-DD&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;05. Right ventricular failure YYYY-MM-DD/YYYY-MM-DD &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;06. Atrial flutter YYYY-MM-DD/YYYY-MM-DD&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the simple SAS code&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc export data=finalae outfile="&amp;amp;maindir.Output\STUDYID Serious and non-serious AEs &amp;amp;tlfdt..xlsx" label replace dbms=xlsx ;&lt;BR /&gt;sheet='STUDYID_AE_MH_CM' ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have suggestions on how I can do this? Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 20:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909531#M358724</guid>
      <dc:creator>TaniaRTP</dc:creator>
      <dc:date>2023-12-22T20:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909550#M358738</link>
      <description>&lt;P&gt;What is defined length of the variable(s) that you need to do this with? Proc Contents will tell you this if you don't know.&lt;/P&gt;
&lt;P&gt;What is the longest actual value (may not match the defined length) but need to know because if the longest current value is 40 characters and the variable has a defined length of 42 then there is no way to insert 5 characters into your existing variable without losing data (40 + 5= 45 means 3 too many characters) and you would need a new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we know from the values in the variable(s) where the line break gets inserted? This could get pretty complicated as with all those YYYY-MM-DD that you show then a simple search for 0 or 01 is likely to not be sufficient.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 23:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909550#M358738</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-22T23:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909572#M358747</link>
      <description>&lt;P&gt;By design PROC EXPORT is for exporting to Excel with minimal formatting options. I suggest you try ODS EXCEL working with PROC REPORT as that gives you far more formatting capabilities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I question your requirement to store multiple medical conditions in one cell. What if you want to report on the number of hypoxias, for example? You can't easily filter your data by condition. It would be better to create one row per condition if you want to do that type of analysis.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 22:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909572#M358747</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-12-23T22:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909624#M358760</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
x='01. Seasonal allergy /Ongoing  '|| "0D0A"x ||'
02. Appendicectomy YYYY/YYYY '|| "0D0A"x ||'
03. Hypoxia YYYY-MM/Ongoing  '|| "0D0A"x ||'
04. Hypoxia YYYY-MM-DD/YYYY-MM-DD  '|| "0D0A"x ||'
05. Right ventricular failure YYYY-MM-DD/YYYY-MM-DD  '|| "0D0A"x ||'
06. Atrial flutter YYYY-MM-DD/YYYY-MM-DD';
run;
proc export data=x outfile="c:\temp\AEs.xlsx" label replace dbms=xlsx ;
sheet='STUDYID_AE_MH_CM' ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_1-1703490672076.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92060i7A44389D05EE4F9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1703490672076.png" alt="Ksharp_1-1703490672076.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_2-1703490704715.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92061iF466B7B4B6C69F86/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_2-1703490704715.png" alt="Ksharp_2-1703490704715.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Dec 2023 07:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909624#M358760</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-12-25T07:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909771#M358819</link>
      <description>&lt;P&gt;Thank you for your advice. I previously used '0A'x to force a break. I inserted "0D0A"x too. Neither worked with the Carriage break (also called Wrap Text) feature in Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TaniaRTP_0-1703713520270.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92092iA1B3E0CF90B624D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TaniaRTP_0-1703713520270.png" alt="TaniaRTP_0-1703713520270.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 21:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909771#M358819</guid>
      <dc:creator>TaniaRTP</dc:creator>
      <dc:date>2023-12-27T21:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909774#M358820</link>
      <description>&lt;P&gt;Adding newline character '0A'x will only do the job if &lt;EM&gt;wrap text&lt;/EM&gt; is also selected for the cell.&lt;/P&gt;
&lt;P&gt;Proc Export is for writing data sheets where formatting is of no relevance. If you're more after a report then consider using ODS Excel together with Proc Report as this will give you a lot of formatting options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here some sample code how this could look like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let xlsx_file=c:\temp\AEs.xlsx;
%let xlsx_sheet=STUDYID_AE_MH_CM;

data have;
  col1='01. Seasonal allergy /Ongoing  ';
  col2='02. Appendicectomy YYYY/YYYY ';
  col3='03. Hypoxia YYYY-MM/Ongoing';
  col4='04. Hypoxia YYYY-MM-DD/YYYY-MM-DD';
  col5='05. Right ventricular failure YYYY-MM-DD/YYYY-MM-DD';
  col6='06. Atrial flutter YYYY-MM-DD/YYYY-MM-DD';
run;

data inter;
  set have;
  length MHDeets $4000;
  MHDeets=catx('0A'x, of col:);
  drop col:;
run;

ods excel 
  file="&amp;amp;xlsx_file" 
  options(
    flow = "Tables" 
    sheet_name="&amp;amp;xlsx_sheet"
    )
  ; 
proc report data=inter nowd wrap;
  column MHDeets;
  define MHDeets /display style(column)={vjust=center width=40em};
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Consider to not creating this concatenated string with line feeds but to write these string on multiple lines. Not only will this avoid changing your source strings but it should also make it easier to filter your data in Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my environment: If using Proc Export for the variable with the linefeed added &lt;EM&gt;wrap text&lt;/EM&gt; did not get selected on the Excel cell. The moment I've added this manually to the Excel cell the text got wrapped as desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 00:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909774#M358820</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-28T00:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909914#M358857</link>
      <description>&lt;P&gt;This should've been accepted as solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After seeing another user's response that wrap text also worked for them, I started reviewing. One of the last manipulations was to strip unprintable characters.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 22:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909914#M358857</guid>
      <dc:creator>TaniaRTP</dc:creator>
      <dc:date>2023-12-29T22:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909917#M358859</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;for your feedback and for simplifying my life with CATX function tip.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output structure was developed &amp;amp; approved several years ago; one row per event. Now, I am adding a few additional columns however these columns are not the focus of the list and won't be used for filtering. The end users need to see a list of which ConMeds were taken within 30 days of the event, what terms are in the subject's Med Hx, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I saw that you were able to wrap in your environment with '0A'x, it was evident that something else was wrong with my environment or the program.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 23:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909917#M358859</guid>
      <dc:creator>TaniaRTP</dc:creator>
      <dc:date>2023-12-29T23:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909924#M358862</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/231260"&gt;@TaniaRTP&lt;/a&gt;&amp;nbsp; I'd still go for ODS Excel together with Proc Report as this just gives you so much more control - now and for future requirements.&lt;/P&gt;
&lt;P&gt;Below sample code demonstrates how to just print the rows while at the same time also creating your concatenated variable&amp;nbsp;MHDeets.&lt;/P&gt;
&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s answer &lt;A href="https://communities.sas.com/t5/ODS-and-Base-Reporting/Splitting-string-into-multiple-lines-via-PROC-REPORT/td-p/392706" target="_self"&gt;here&lt;/A&gt; I also was able to impute the line breaks differently so they'll work also with other output destinations like HTML.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let xlsx_file=c:\temp\AEs.xlsx;
%let xlsx_sheet=STUDYID_AE_MH_CM;

data have;
  other_var='Row 1';
  col1='01. Seasonal allergy /Ongoing  ';
  col2='02. Appendicectomy YYYY/YYYY ';
  col3='03. Hypoxia YYYY-MM/Ongoing';
  col4='04. Hypoxia YYYY-MM-DD/YYYY-MM-DD';
  col5='05. Right ventricular failure YYYY-MM-DD/YYYY-MM-DD';
  col6='06. Atrial flutter YYYY-MM-DD/YYYY-MM-DD';
  output;
  call missing(col2,col3,col5,col6);
  other_var='Row 2';
  output;
run;

proc sql noprint;
  select name into :var_list separated by ' '
  from dictionary.columns
  where 
    libname='WORK' 
    and memname='HAVE' 
    and prxmatch('/^col\d+/i',strip(name))&amp;gt;0
    order by name
  ;
quit;

ods excel 
  file="&amp;amp;xlsx_file" 
  options(
    flow = "Tables" 
    sheet_name="&amp;amp;xlsx_sheet"
    )
  ; 
ods escapechar='^';
proc report data=HAVE nowd style(header)={just=l} style(column)={vjust=center};
  column col: other_var MHDeets;
  define col: /noprint;
  define other_var  /display;
  define MHDeets    /computed style(column)={width=35em};
  compute MHDeets /character length=4000;
    array _cols{*} &amp;amp;var_list;
    %macro null;
    /* in case there are non-print characters that need removal */
    do _i=1 to dim(_cols);
      _cols[_i]=compress(_cols[_i],,'kw');
    end;
    %mend;
    MHDeets=catx('^n', of _cols[*]);
  endcomp;

run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Excel:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1703902999358.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92132i71D7DA05BF75AA6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_1-1703902999358.png" alt="Patrick_1-1703902999358.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTML when using SAS EG:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1703902942303.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92131iA824C0B6A609FD10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1703902942303.png" alt="Patrick_0-1703902942303.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 02:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/909924#M358862</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-30T02:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need to insert line break in Excel using PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/951771#M372025</link>
      <description>Many tnks for your kindly help I try immediately. Have a nice day. Tecla</description>
      <pubDate>Mon, 25 Nov 2024 10:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-insert-line-break-in-Excel-using-PROC-EXPORT/m-p/951771#M372025</guid>
      <dc:creator>Tecla1</dc:creator>
      <dc:date>2024-11-25T10:31:45Z</dc:date>
    </item>
  </channel>
</rss>

