<?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 to split a variable string in proc report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738295#M230272</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV id="bodyDisplay_49b9780c160674" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;I have a variable "col1" and I want to split the value into a new line in proc report when there's a "/" because there isn't enough space in the rtf.&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;Current output:&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisNZ_0-1619838975529.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58919iD3E093FE7BA9E163/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisNZ_0-1619838975529.png" alt="ChrisNZ_0-1619838975529.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Current code:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data x; 
set y; 
col1= soc ||'/'|| pt; 
run; 

proc report data=final nowindows center headline headskip missing split='@'; 
column col:; 
define col1 / order style(column)={asis=on just=left cellwidth=.8in} flow style(header)={just=left font_size=9pt} "SOC/PT" ;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why&lt;FONT face="courier new,courier"&gt; split='@'&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; and not&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;split='/'&amp;nbsp; &lt;/FONT&gt;if you want to split at / ?&lt;/P&gt;</description>
    <pubDate>Sat, 01 May 2021 03:16:44 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-05-01T03:16:44Z</dc:date>
    <item>
      <title>How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738283#M230263</link>
      <description>&lt;P&gt;I have a variable "col1" and I want to split the value into a new line in proc report when there's a "/" because there isn't enough space in the rtf.&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;Current output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_0-1619820303717.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58918i1BF823B0AB754243/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_0-1619820303717.png" alt="HitmonTran_0-1619820303717.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Current code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x; 
set y; 
col1= soc ||'/'|| pt; 
run; 

proc report data=final nowindows center headline headskip missing split='@'; 
column col:; 
define col1 / order style(column)={asis=on just=left cellwidth=.8in} flow style(header)={just=left font_size=9pt} "SOC/PT" ;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 22:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738283#M230263</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2021-04-30T22:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738295#M230272</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV id="bodyDisplay_49b9780c160674" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;I have a variable "col1" and I want to split the value into a new line in proc report when there's a "/" because there isn't enough space in the rtf.&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;Current output:&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisNZ_0-1619838975529.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58919iD3E093FE7BA9E163/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisNZ_0-1619838975529.png" alt="ChrisNZ_0-1619838975529.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Current code:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data x; 
set y; 
col1= soc ||'/'|| pt; 
run; 

proc report data=final nowindows center headline headskip missing split='@'; 
column col:; 
define col1 / order style(column)={asis=on just=left cellwidth=.8in} flow style(header)={just=left font_size=9pt} "SOC/PT" ;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why&lt;FONT face="courier new,courier"&gt; split='@'&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; and not&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;split='/'&amp;nbsp; &lt;/FONT&gt;if you want to split at / ?&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 03:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738295#M230272</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-05-01T03:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738312#M230282</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x; 
set y; 
col1= soc ||' (*ESC*)n '|| pt; 
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 May 2021 10:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738312#M230282</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-01T10:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738322#M230287</link>
      <description>Because I have columns with dates that uses "/". Either way, if i changed&lt;BR /&gt;"@" to "/" it doesn't work&lt;BR /&gt;</description>
      <pubDate>Sat, 01 May 2021 13:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738322#M230287</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2021-05-01T13:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738326#M230288</link>
      <description>&lt;P&gt;SPLIT works fine for plain old text listing output.&amp;nbsp; But it looks like ODS ignores it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final; 
  soc ='AAAA';
  pt='BBBB';
  col1= soc ||'@'|| pt; 
run; 

proc report data=final nowindows center headline headskip missing split='@'; 
column col:; 
define col1 / order style(column)={asis=on just=left cellwidth=.8in} flow style(header)={just=left font_size=9pt} "SOC/PT" ;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 146px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58922iC3326317ABA0D9B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 153px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58923i4A1A42C4CD6338A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You will need to ODS compatible methods if you want to produce ODS output.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x; 
set y; 
col1= soc ||' (*ESC*)n '|| pt; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 13:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738326#M230288</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-01T13:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738332#M230292</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;SPLIT= is designed to allow control for splitting strings in column headers, not in data cells. Using the ODS ESCAPECHAR NEWLINE function is the best way to achieve what is needed. However, it will mean using a DATA step to alter the code so that \ turns into ESCAPECHAR + {newline 1} -- there is an older method using just ESCAPECHAR+n, but that is an artifact of the original ESCAPECHAR syntax and it might be better to switch to the newest syntax. Or you could use RTF control strings. Here's an example of all 3 methods.&lt;BR /&gt;Cynthia&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="Cynthia_sas_0-1619882075148.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58926i20AED7AF1CE1EF71/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1619882075148.png" alt="Cynthia_sas_0-1619882075148.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code for the above examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fakedata; 
  length socpt $70;
  infile datalines dlm=',';
  input rownum socpt $;
  label socpt = 'Soc@PT'
        rownum = 'Row@Number';
return;
datalines;
10, Twas brillig and the slithy toves/did gyre and gimble in the wabe.
11, All mimsy were the borogroves/and the momeraths outgrabe.
;
run;

data newdata;
  length first last $70 newsoc soc2 soc3 $90;
  set fakedata;
  first = scan(socpt,1,'/');
  last = scan(socpt,2,'/');
  newsoc = catx('^{newline 1}',first,last);
  soc2 = catx('^n',first,last);
  soc3 = catx(' \line ',first,last);
run;

options orientation=landscape topmargin=.25in bottommargin=.25in 
        rightmargin=.25in leftmargin=.25in;
ods escapechar='^';
Title; Footnote;
  
ods rtf file='c:\temp\newline_datacell.rtf' startpage=no;
proc report data=newdata split='@';
  column rownum socpt newsoc;
  define rownum / order;
  define socpt / display 'Original@SocPT';
  define newsoc / display 'Soc PT@using new Escapechar';
  compute before _page_/style=Header;
    line 'Using New Escapechar';
  endcomp;
run;
    
proc report data=newdata split='@';
  column rownum socpt soc2;
  define rownum / order;
  define socpt / display 'Original@SocPT';
  define soc2 / display 'Soc PT@using old Escapechar';
  compute before _page_/style=Header;
    line 'Using Old Escapechar';
  endcomp;
run;
  
proc report data=newdata split='@';
  column rownum socpt soc3;
  define rownum / order;
  define socpt / display 'Original@SocPT';
  define soc3 / display 'Soc PT@using RTF control string'
         style(column)={protectspecialchars=off};
  compute before _page_/style=Header;
    line 'Using RTF Control Strings';
  endcomp;
run;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 15:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738332#M230292</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-05-01T15:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738334#M230293</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi:&lt;BR /&gt;SPLIT= is designed to allow control for splitting strings in column headers, not in data cells.&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note that is not really a true statement since the SPLIT= option has always worked for splitting content for the listing output.&lt;/P&gt;
&lt;P&gt;Perhaps you mean they only implemented the SPLIT= option for headers when they added ODS support?&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 15:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738334#M230293</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-01T15:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738356#M230309</link>
      <description>&lt;P&gt;Hi, Tom:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; That was the way I remembered it too. But then I tested in 9.4M7 and found something different. Here's my LISTING output using / inside a datacell:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1619900452583.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58927i884EFAB1BBFC6762/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1619900452583.png" alt="Cynthia_sas_0-1619900452583.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; So I think you're right that it used to work that way in SAS 5 and 6 and even possibly after the formal ODS introduction in 8, but that's not what I could generate today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 20:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738356#M230309</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-05-01T20:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738366#M230313</link>
      <description>&lt;P&gt;Did they change it in 9.4M7 ?&amp;nbsp; Because the example I posted above is from 9.4M5 and it definitely split the value on the split character.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to use the FLOW option on the column definition in PROC REPORT.&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 02:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738366#M230313</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-02T02:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a variable string in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738423#M230351</link>
      <description>&lt;P&gt;Tom:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; My bad. You're right. With the FLOW option, the LISTING destination honors the split character:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1619980776686.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58933i1229650708BC8DD5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1619980776686.png" alt="Cynthia_sas_0-1619980776686.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But FLOW is a LISTING-only option so, it is ignored for other ODS destinations like RTF, PDF and HTML. What I should have clarified in my original post was:&lt;/P&gt;
&lt;P&gt;SPLIT= is designed to allow control for splitting strings in column headers, not in data cells &lt;EM&gt;&lt;STRONG&gt;for most ODS destinations like RTF, PDF and HTML&lt;/STRONG&gt;&lt;/EM&gt;. The SPLIT= option can be used in LISTING output for data cells (with the FLOW option in PROC REPORT), but ODS STYLE overrides are not used by the LISTING destination. If you want the data cells to be split in ODS destinations like RTF, PDF and HTML, then the workaround is to use ODS ESCAPECHAR or, for RTF, RTF control strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I find fewer students using LISTING output especially when working in SAS Studio with server-based SAS, so thanks for giving me the chance to refresh my LISTING skills.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 18:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-split-a-variable-string-in-proc-report/m-p/738423#M230351</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-05-02T18:50:27Z</dc:date>
    </item>
  </channel>
</rss>

