<?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 row to multiple rows? in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58843#M1482</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it base on Art's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp; informat string $80.;
&amp;nbsp; input string &amp;amp;;
&amp;nbsp; cards;
The power to know
The power to know something
The power to know how to do something else
;
run;

data want (keep=want_string);
&amp;nbsp; set have;
&amp;nbsp; length _string $ 80 want_string $ 11;
&amp;nbsp; retain _string;
&amp;nbsp; i=1;temp=scan(string,1);
&amp;nbsp; do while(not missing(temp));
&amp;nbsp;&amp;nbsp; _string=catx(' ',_string,temp);
&amp;nbsp;&amp;nbsp; if length(_string) gt lengthc(want_string) then do;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; want_string=substr(_string,1,length(_string)-length(scan(_string,-1))-1);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;_string=scan(_string,-1);end;
&amp;nbsp;&amp;nbsp; i+1;temp=scan(string,i);
&amp;nbsp;&amp;nbsp; if missing(temp) then do;want_string=_string;output;end;
&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp; call missing(_string);
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 Dec 2011 05:23:32 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-12-03T05:23:32Z</dc:date>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58831#M1470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me with this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I split a string in a row to multiple rows, say there is variable called string='The Power to Know'. I was able to split it based on the delimiter using 'DO UNTIL' and 'SCAN' and the output would be something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;String&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&lt;/P&gt;&lt;P&gt;Power&lt;/P&gt;&lt;P&gt;to &lt;/P&gt;&lt;P&gt;Know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But am looking for the output some thing like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;String&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Power&lt;/P&gt;&lt;P&gt;to Know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 03:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58831#M1470</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-02T03:48:37Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58832#M1471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my question is WHERE do you want to split the string. Let's say you do have a variable called STRING whose value is "The Power to Know" -- where do you want to split it? A dataset has no concept of a split line. A split or a line feed or a carriage return usually belong to a cell in a report. So I could see how you might want to display, in a report, like an RTF file or an HTML file or a PDF file, the single string "The Power to Know" on 4 lines of the report or on 2 lines of the report. But I don't understand what the point is of "splitting the string" into rows. Does that mean that if your original dataset is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;obs var1&amp;nbsp;&amp;nbsp; var2 string &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xxx&amp;nbsp;&amp;nbsp;&amp;nbsp; yyy&amp;nbsp; The Power to Know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that you want to create a new dataset with 2 rows???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;obs var1 var2 string&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xxx&amp;nbsp; yyy&amp;nbsp; The Power&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xxx&amp;nbsp; yyy&amp;nbsp; to Know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, in an output report, such as from PROC PRINT or PROC REPORT, do you want to see the string "The Power to Know" displayed on 2 lines of the output report instead of 1 line?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 05:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58832#M1471</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-12-02T05:25:54Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58833#M1472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thanks for your time. I was able to do it for the display purpose using Proc Report or ODS but was wondering whether it can be done in dataset and yes, I was looking for something like you said. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;obs var1&amp;nbsp;&amp;nbsp; var2 string&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xxx&amp;nbsp;&amp;nbsp;&amp;nbsp; yyy&amp;nbsp; The Power to Know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;that you want to create a new dataset with 2 rows???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;obs var1 var2 string&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xxx&amp;nbsp; yyy&amp;nbsp; The Power&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xxx&amp;nbsp; yyy&amp;nbsp; to Know&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;Thanks&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;sasjourney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 05:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58833#M1472</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-02T05:57:19Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58834#M1473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Back to Cynthia's question: where do yo want to split the line?&lt;/P&gt;&lt;P&gt;You need some kind of rule. Is the rule to split after two words in the string?&lt;/P&gt;&lt;P&gt;If so, you can probably achieve what you want to play a bit further with scan and until...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 07:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58834#M1473</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2011-12-02T07:48:43Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58835#M1474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, in this example I want to split it after two words. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;sasjourney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 15:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58835#M1474</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-02T15:19:57Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58836#M1475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you just asking how you would do something like the following?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat string $80.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input string &amp;amp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;The power to know&lt;/P&gt;&lt;P&gt;The power to know something&lt;/P&gt;&lt;P&gt;The power to know how to do something else&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want (keep=want_string);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length want_string $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; counter=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; nomore=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (nomore);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if scan(string,counter) eq "" then nomore=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else want_string=&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catx(' ',want_string,scan(string,counter));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if mod(counter,2) eq 0 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(want_string);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58836#M1475</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-12-02T16:08:26Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58837#M1476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There you go. It worked perfectly for me, Thank you.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, is there anyway that it can de done based on the length of the column. Say it is need to be split at a length of 11 in "The Power to Know how to do something else"&lt;/P&gt;&lt;P&gt;the first 11 characters would be "The Power t" but i don't want that to happen because that would split the word "to". instead I want to check the length and split it till there if it not splitting the word&amp;nbsp; and split till the previous delimiter if it is splitting the word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58837#M1476</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-02T16:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58838#M1477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have to chime in again and say this sounds like a reporting issue and text wrapping on a report rather than a dataset issue. Or maybe I'm just dense and don't get the point. I don't understand how, in a DATASET, it would be useful to break a single obs into two obs so one observation has 11 characters of a text string and then a second observation in a DATASET has the rest of the text string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; If you use ODS to create your report output, then ODS will take care of wrapping and won't break a word in the middle of two letters unless there are no spaces in the text string. Will ODS split after EXACTLY 11 characters??? Not automatically. Can you make ODS split in a report table after EXACTLY 11 characters, yes, you can.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; You would use a program similar to Art's program, but would insert a "line feed" or "carriage return" character into the text string in order to influence where ODS broke the text string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; You said that you got the results you wanted in your report. So, what purpose is served by splitting your observations in a DATASET? Was the line breaking or line wrapping in the report not to your liking? Did you use the CELLWIDTH or WIDTH style attribute to control the wide of the cell? (Which influences how much text can wrap) What is your destination of interest? Is this really a DATASET issue or a REPORT issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; For example, in the report below, see the difference in wrapping based just on using the CELLWIDTH style attribute and then compare that to the use wrapping in the cell when CELLWIDTH is used with ODS ESCAPECHAR newline capability.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;data testit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; length charvar1 charvar2 charvar3 $200 charvar4 $600;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; set sashelp.class;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; where age gt 14;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; charvar1 = 'Twas brillig and the slithy toves did gyre and gimble in the wabe.';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; charvar2 = 'All mimsy were the borogroves and the mome raths outgrabe.';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; charvar3 = 'Beware the Jabberwock, my son!~nThe jaws that bite, the claws that snatch.';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; charvar4 = catx('~n',charvar1,charvar2,charvar3);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;options orientation=landscape topmargin=.25in bottommargin=.25in&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leftmargin=.25in rightmargin=.25in;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods listing close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html file='c:\temp\wrap.html' style=sasweb;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods rtf file='c:\temp\wrap.rtf';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods pdf file='c:\temp\wrap.pdf';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods escapechar='~';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** note that charvar3 and charvar4 have&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; explicit line feed characters&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; using ODS ESCAPECHAR+n or ~n&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; for RTF, PDF and HTML. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; In 9.3 can use ~{newline 1} instead of ~n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc print data=testit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title 'Proc Print';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var charvar1 / style(data)={cellwidth=.5in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var charvar2 /style(data)={cellwidth=1.5in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var charvar3 / style(data)={cellwidth=3in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var charvar4 / style(data)={cellwidth=4in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var name;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=testit nowd;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title 'Proc Report';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column charvar1 charvar2 charvar3 charvar4 name;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define charvar1 / display style(column)={cellwidth=.5in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define charvar2/ display style(column)={cellwidth=1.5in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define charvar3 / display&amp;nbsp; style(column)={cellwidth=3in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define charvar4 / display style(column)={cellwidth=4in};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define name/ display;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods _all_ close;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 17:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58838#M1477</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-12-02T17:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58839#M1478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with Cynthia that it would help to know what you are trying to accomplish this for.&amp;nbsp; Splitting can be done, but what would you do if a word was greater than 11 characters long?&amp;nbsp; If you take Cynthia's examples, what would you call a word?&amp;nbsp; Just any string that is separated by a space?&amp;nbsp; Or wouldn't you want to split on various characters and, if so, which ones?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can answer those questions, and you are doing what you ask for a reason, then you can probably figure it out yourself by just expanding the code to include those conditions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 17:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58839#M1478</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-12-02T17:58:43Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58840#M1479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with both of you, I do not have any problems while creating a report (Thanks to ODS). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the reason I wanted to split the string was, we got the data in an excel sheet, in which they entered the longstrings on two or more rows for readability(instead of wrapping) and now I have the same string in a different dataset as a single line. Now, when I import the excel sheet into sas, a single string is on different rows(manually entered into different rows). so there is no way for me to match the dataset to the dataset from excel for flagging purposes without splitting the string in dataset. So, when I spoke with them(who created the excel data), they said that they are wrapping/splitting the text based on length. And yes, I asked the same question, what if the length of the word is more than the length set for splitting, they said that if that is the case there is no way other than to split the word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, if I miss something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;sasjourney&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 19:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58840#M1479</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-02T19:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58841#M1480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can write a program to do this, but I have had success in the past with just letting SAS do it for me.&lt;/P&gt;&lt;P&gt;Make sure you have a simple unique ID for each observation. Then use proc report to produce a text listing that will flow the long strings for you and read it back in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length id 8 string $200;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id=1; string='this is too long for 12 colums';&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id+1; string='Another long string that will wrap to multiple rows';&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename tempfile temp;&lt;/P&gt;&lt;P&gt;proc printto print=tempfile new; run;&lt;/P&gt;&lt;P&gt;proc report data=have nofs spacing=1 split='FF'x nocenter ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; title1 'DUMP';&lt;/P&gt;&lt;P&gt;&amp;nbsp; column id string;&lt;/P&gt;&lt;P&gt;&amp;nbsp; define id / 'ID' order order=internal display width=4 spacing=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; define string / display flow width=12;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;title1;&lt;/P&gt;&lt;P&gt;proc printto print=print; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data short;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length id 8 short $12;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile tempfile truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input check $4. @5 short $12.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if check in ('DUMP','ID') or short=' ' then delete;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if check ^= ' ' then id=input(check,4.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop check;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge short have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 19:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58841#M1480</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-12-02T19:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58842#M1481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks Tom, I will give it a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 21:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58842#M1481</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-02T21:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58843#M1482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it base on Art's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp; informat string $80.;
&amp;nbsp; input string &amp;amp;;
&amp;nbsp; cards;
The power to know
The power to know something
The power to know how to do something else
;
run;

data want (keep=want_string);
&amp;nbsp; set have;
&amp;nbsp; length _string $ 80 want_string $ 11;
&amp;nbsp; retain _string;
&amp;nbsp; i=1;temp=scan(string,1);
&amp;nbsp; do while(not missing(temp));
&amp;nbsp;&amp;nbsp; _string=catx(' ',_string,temp);
&amp;nbsp;&amp;nbsp; if length(_string) gt lengthc(want_string) then do;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; want_string=substr(_string,1,length(_string)-length(scan(_string,-1))-1);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;_string=scan(_string,-1);end;
&amp;nbsp;&amp;nbsp; i+1;temp=scan(string,i);
&amp;nbsp;&amp;nbsp; if missing(temp) then do;want_string=_string;output;end;
&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp; call missing(_string);
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Dec 2011 05:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58843#M1482</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-12-03T05:23:32Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58844#M1483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for helping me out on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sasjourney.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 20:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58844#M1483</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2011-12-05T20:35:43Z</dc:date>
    </item>
    <item>
      <title>How to Split a row to multiple rows?</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58845#M1484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm a bit late to this thread, but if you're doing clinical programming, I recommend having a look at &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.datasavantconsulting.com/roland/Spectre/maclist2.html"&gt;http://www.datasavantconsulting.com/roland/Spectre/maclist2.html&lt;/A&gt;&lt;SPAN&gt;, specifically &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.datasavantconsulting.com/roland/Spectre/utilmacros/splitvar.sas"&gt;http://www.datasavantconsulting.com/roland/Spectre/utilmacros/splitvar.sas&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; You may find this macro meets your needs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Dec 2011 12:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/How-to-Split-a-row-to-multiple-rows/m-p/58845#M1484</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2011-12-20T12:37:06Z</dc:date>
    </item>
  </channel>
</rss>

