<?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: Merge cell vertically in proc report, with missing cells, keep the order of file in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/441318#M20565</link>
    <description>&lt;P&gt;One way would be to change the value of the missings to different non printable characters.&amp;nbsp; This version of the CONTROL data set will insert nonprintable values into cells with missing values.&amp;nbsp; because they are different they will not group but will still be blank.&amp;nbsp; You would need to adjust the code if there are more than 30 or so missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input variable $ @10 group $1. @13 num;
datalines;
name        1
drugA       2
drugB    D  3
d_drug01 B  4
d_drug02 B  5
d_drug03 B  6
d_drug04 B  7
d_drug05 B  8
d_drug06 B  9
d_drug07 B  10
DrugF    C  11
DrugX    F  12
Drugy       13
Drugz       14
Drugq       15
Drugr       16
run;
data control(keep=fmtname start label);
   retain fmtname 'numord';
   set have(rename=(num=start));
   if group=' ' then do;
      cnt+1;
      label=byte(4+put(cnt,3.));
   end;
   else label=group;
   run;

proc format cntlin=control;
   run;

proc report data=have spanrows;
   column num variable;
   define num / order f=numord1. order=internal
                style(column)={vjust=c just=c};
   define variable / display;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The BYTE function creates a hex code.&amp;nbsp; Hex codes from 0 - 31 are not printable so will appear as blanks (some nonprintable characters actually print in some fonts).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seems like a hack to me so i am hoping someone else will come up with something more robust.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Mar 2018 18:32:09 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2018-03-01T18:32:09Z</dc:date>
    <item>
      <title>Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440388#M20525</link>
      <description>&lt;P&gt;The original table was sorted by&amp;nbsp; "Num".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to&lt;/P&gt;&lt;P&gt;1. merge the cells in column "group"&amp;nbsp;if they have the same value and if they are adjacent ("Num" value are contiguous).&lt;/P&gt;&lt;P&gt;2. The new table will keep the same order .&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. The missing cells will not merge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Original SAS dataset is:&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Variable&lt;/TD&gt;&lt;TD&gt;Group&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugL&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugZ&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugC&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugD&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugE&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugF&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugX&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugH&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugI&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugJ&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugK&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;drugL&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ideal output table is attached. Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 20:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440388#M20525</guid>
      <dc:creator>SSH2</dc:creator>
      <dc:date>2018-02-27T20:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440393#M20526</link>
      <description>&lt;P&gt;I am not sure exactly what you mean by 'merged cells'.&amp;nbsp; That term has a specific meaning that to me is not implied by your question.,&amp;nbsp; So let me take a guess and see if it gets us closer.&amp;nbsp; Do you mean that you do not want the GROUP variable to not repeat?&amp;nbsp; If so then we can control order and the display of the GROUP variable through the use of a format.&amp;nbsp; The following creates a format that can then be used as a grouping variable without the complicating NUM variable on the COLUMN statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input variable $ @10 group $1. @13 num;
datalines;
name        1
drugA       2
drugB    D  3
d_drug01 B  4
d_drug02 B  5
d_drug03 B  6
d_drug04 B  7
d_drug05 B  8
d_drug06 B  9
d_drug07 B  10
DrugF    C  11
DrugX    F  12
run;
data control(keep=fmtname start label);
   retain fmtname 'numord';
   set have(rename=(num=start group=label));
   run;

proc format cntlin=control;
   run;
proc report data=have;
   column num variable;
   define num / group f=numord.;
   define variable / display;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 06:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440393#M20526</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2018-02-27T06:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440522#M20528</link>
      <description>&lt;P&gt;Thank you very much ArtC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry I confused you.&amp;nbsp; There is new condition just added. I edited the original question. Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 20:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440522#M20528</guid>
      <dc:creator>SSH2</dc:creator>
      <dc:date>2018-02-27T20:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440621#M20531</link>
      <description>&lt;P&gt;The SPANROWS option will get you closer, however the missing cells will also merge.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have spanrows;
   column num variable;
   define num / group f=numord. style(column)={vjust=c just=c};
   define variable / display;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Feb 2018 18:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440621#M20531</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2018-02-27T18:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440654#M20532</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; I tried the spanrows. But it is not ideal&amp;nbsp;when there is missing cells. I don't want to merge the missing cells. Thank you very much&amp;nbsp;for your time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 20:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/440654#M20532</guid>
      <dc:creator>SSH2</dc:creator>
      <dc:date>2018-02-27T20:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/441318#M20565</link>
      <description>&lt;P&gt;One way would be to change the value of the missings to different non printable characters.&amp;nbsp; This version of the CONTROL data set will insert nonprintable values into cells with missing values.&amp;nbsp; because they are different they will not group but will still be blank.&amp;nbsp; You would need to adjust the code if there are more than 30 or so missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input variable $ @10 group $1. @13 num;
datalines;
name        1
drugA       2
drugB    D  3
d_drug01 B  4
d_drug02 B  5
d_drug03 B  6
d_drug04 B  7
d_drug05 B  8
d_drug06 B  9
d_drug07 B  10
DrugF    C  11
DrugX    F  12
Drugy       13
Drugz       14
Drugq       15
Drugr       16
run;
data control(keep=fmtname start label);
   retain fmtname 'numord';
   set have(rename=(num=start));
   if group=' ' then do;
      cnt+1;
      label=byte(4+put(cnt,3.));
   end;
   else label=group;
   run;

proc format cntlin=control;
   run;

proc report data=have spanrows;
   column num variable;
   define num / order f=numord1. order=internal
                style(column)={vjust=c just=c};
   define variable / display;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The BYTE function creates a hex code.&amp;nbsp; Hex codes from 0 - 31 are not printable so will appear as blanks (some nonprintable characters actually print in some fonts).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seems like a hack to me so i am hoping someone else will come up with something more robust.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 18:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/441318#M20565</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2018-03-01T18:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merge cell vertically in proc report, with missing cells, keep the order of file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/444836#M20612</link>
      <description>&lt;P&gt;Thank you very much!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I found a solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a1;&lt;/P&gt;&lt;P&gt;set a;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if group=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;""&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; then group=&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"ZZZ"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;data a2;&lt;/P&gt;&lt;P&gt;set a1;&lt;/P&gt;&lt;P&gt;by&amp;nbsp;group notsorted num notsorted;&lt;/P&gt;&lt;P&gt;retain cnt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if first.group then cnt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;cnt+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;proc report data=a2&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;spanrows&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;column&amp;nbsp; &amp;nbsp;group num cnt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;define&amp;nbsp;group / group style(column)={ cellwidth=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;in bordercolor=black vjust=c just=l } order=data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;define cnt / order order=internal noprint;&lt;/P&gt;&lt;P&gt;define num / order order=data noprint;&lt;/P&gt;&lt;P&gt;compute group;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if index(group, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"ZZZ"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) then group=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;""&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;endcomp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your time!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 16:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Merge-cell-vertically-in-proc-report-with-missing-cells-keep-the/m-p/444836#M20612</guid>
      <dc:creator>SSH2</dc:creator>
      <dc:date>2018-03-12T16:52:27Z</dc:date>
    </item>
  </channel>
</rss>

