<?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 Can I Output Result as Desired Order in RTF? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590267#M168902</link>
    <description>&lt;P&gt;&lt;EM&gt;&amp;gt; you also changed code in PROC REPORT, right?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course since it didn't do what you wanted&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think formatting should be done by changing the data, but this kludge works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data FINAL;
    set TEST_1;
    by PAGE SORT1 SORT2;
    output;
    if last.PAGE then do;
        call missing( SUBJID, VALUE);
        FLG_LINE=1; 
        SORT2+1;      COHORT='Z'; 
        output;
    end;
run;
ods rtf file="%Sysfunc(pathname(WORK))\test.rtf";
proc report data=FINAL missing out=DATA
    style(header)={backgroundcolor=white}
    style(report)={rules=groups frame=above} ;
  column PAGE COHORT SUBJID VALUE ;
  define PAGE    / order order=internal noprint;
  define COHORT  / group;
  define SUBJID  / group;
  define VALUE   / group;
  break after page / ; 
  compute after _page_;
    line "footnote";
  endcomp;
  compute cohort;
    if _C2_='Z' then call define(_row_, "style", "style={bordertopcolor=black bordertopstyle=solid bordertopwidth=0.5pt
                                                  color=white
                                                  borderbottomcolor=black borderbottomstyle=solid borderbottomwidth=0.5pt}");
  endcomp;
run;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture .PNG" style="width: 199px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32634iD50DBF3839D16C62/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture .PNG" alt="Capture .PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Sep 2019 05:46:11 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-09-20T05:46:11Z</dc:date>
    <item>
      <title>How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590240#M168890</link>
      <description>&lt;P&gt;Hello, there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating RTF output and stuck in one problem.&lt;/P&gt;&lt;P&gt;I want to output in the order below.&lt;/P&gt;&lt;P&gt;(Result Body) -&amp;gt; (One Blank Row between Solid Line) -&amp;gt; (Footnote)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is below, and I do not know where problem is.&lt;/P&gt;&lt;P&gt;Before running PROC REPORT, I sorted by my desired order, but PROC REPORT's output (I used OUT= option in PROC REPORT) seems not to be sorted (One blank row located in strange position, not after Result Body).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice is welcome. Thank you in advance.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    input sort1 cohort$ sort2 subjid$ value$;
    datalines;
    1 A 1 A-01 xx
    1 A 2 A-02 xx
    2 B 3 B-01 xx
    2 B 4 B-02 xx
    2 B 5 B-03 xx
    ;
run;
proc sort data=test;
    by sort1 sort2;
run;
data test_1;
    set test;
    by sort1 sort2;


    if mod(_n_-1, 12) eq 0 then page+1;
run;
proc sort data=test_1;
    by page sort1 sort2;
run;
data final;
    set test_1;
    by page sort1 sort2;


    output;


    if last.page eq 1 then do;
        call missing(of cohort subjid value);
        flg_line=1;
        output;
    end;
run;
ods rtf file="Please Specify Your Own Folder\test.rtf";
proc report data=final missing out=data
    style(header)={backgroundcolor=white}
    style(report)={rules=groups frame=above}
    ;
    column page sort1 cohort sort2 subjid value flg_line;
    define page / order order=internal noprint;
    define sort1 / order order=internal noprint;
    define cohort / order "COHORT";
    define sort2 / order order=internal noprint;
    define subjid / display "SUBJECT";
    define value / display "VALUE";
    define flg_line / order order=internal noprint;
    break after page / page;
    compute after _page_;
        line "footnote";
    endcomp;
    compute flg_line;
        if flg_line eq 1 then do;
            call define(_row_, "style", "style(calldef)={bordertopcolor=black bordertopstyle=solid bordertopwidth=0.5pt
                borderbottomcolor=black borderbottomstyle=solid borderbottomwidth=0.5pt}");
        end;
    endcomp;
run;
quit;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 00:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590240#M168890</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2019-09-20T00:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590256#M168898</link>
      <description>&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data FINAL;
    set TEST_1;
    by PAGE SORT1 SORT2;
    output;
    if last.PAGE then do;
        call missing(COHORT, SUBJID, VALUE);
        FLG_LINE=1; 
        SORT2+1;       * &amp;lt;=== Added this line  ;
        output;
    end;
run;
ods rtf file="%Sysfunc(pathname(WORK))\test.rtf";
proc report data=FINAL missing out=DATA
    style(header)={backgroundcolor=white}
    style(report)={rules=groups frame=above} ;
  column PAGE SORT2 COHORT  SUBJID VALUE FLG_LINE;
  define PAGE    / order order=internal noprint;
  define SORT2   / order order=internal noprint;
  define FLG_LINE/ order order=internal noprint;
  define COHORT  / order "COHORT";
  define SUBJID  / display "SUBJECT";
  define VALUE   / display "VALUE";
  break after page /;
  compute after _page_;
    line "footnote";
  endcomp;
  compute flg_line;
    if flg_line eq 1 then  
      call define(_row_, "style", "style(calldef)={bordertopcolor=black bordertopstyle=solid bordertopwidth=0.5pt
                                       borderbottomcolor=black borderbottomstyle=solid borderbottomwidth=0.5pt}");
  endcomp;
run;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture .PNG" style="width: 233px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32632i6B5EAC7312132878/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture .PNG" alt="Capture .PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 04:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590256#M168898</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-20T04:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590262#M168901</link>
      <description>&lt;P&gt;Hi, ChrisNZ-san:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reply.&lt;/P&gt;&lt;P&gt;Your idea seems to be good, but you also changed code in PROC REPORT, right?&lt;/P&gt;&lt;P&gt;if there are duplicate values in Variable COHORT, I want to display only first unique value, so I write code like what I inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my previous code, I had already tried your idea, but did not work.&lt;/P&gt;&lt;P&gt;I have no idea, please help me.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 04:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590262#M168901</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2019-09-20T04:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590267#M168902</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; you also changed code in PROC REPORT, right?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course since it didn't do what you wanted&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think formatting should be done by changing the data, but this kludge works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data FINAL;
    set TEST_1;
    by PAGE SORT1 SORT2;
    output;
    if last.PAGE then do;
        call missing( SUBJID, VALUE);
        FLG_LINE=1; 
        SORT2+1;      COHORT='Z'; 
        output;
    end;
run;
ods rtf file="%Sysfunc(pathname(WORK))\test.rtf";
proc report data=FINAL missing out=DATA
    style(header)={backgroundcolor=white}
    style(report)={rules=groups frame=above} ;
  column PAGE COHORT SUBJID VALUE ;
  define PAGE    / order order=internal noprint;
  define COHORT  / group;
  define SUBJID  / group;
  define VALUE   / group;
  break after page / ; 
  compute after _page_;
    line "footnote";
  endcomp;
  compute cohort;
    if _C2_='Z' then call define(_row_, "style", "style={bordertopcolor=black bordertopstyle=solid bordertopwidth=0.5pt
                                                  color=white
                                                  borderbottomcolor=black borderbottomstyle=solid borderbottomwidth=0.5pt}");
  endcomp;
run;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture .PNG" style="width: 199px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32634iD50DBF3839D16C62/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture .PNG" alt="Capture .PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 05:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590267#M168902</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-20T05:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590371#M168957</link>
      <description>&lt;P&gt;Hi, ChrisNZ-san:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really thank you for your cooperation.&lt;/P&gt;&lt;P&gt;I understand your trick, COHORT=Z displayed, but seems to disappear by using COLOR=WHITE.&lt;/P&gt;&lt;P&gt;It looks okay, but are there any other better resolutions?&lt;/P&gt;&lt;P&gt;If possible, I want to resolve this problem by not using COLOR=WHITE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And if anyone know why this problem happened in my code, please let me know.&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590371#M168957</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2019-09-20T13:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590376#M168961</link>
      <description>&lt;P&gt;Thank you, ChrisNZ-san.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank to your hint, I added SORT1+1 in my code, and I accomplished my objective.&lt;/P&gt;&lt;P&gt;I think (first variable for sorting+1) is important.&lt;/P&gt;&lt;P&gt;But I do not understand why.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thanks!!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
    set test_1;
    by page sort1 sort2;


    output;


    if last.page eq 1 then do;
        call missing(of cohort subjid value);
        sort1+1;          ************ Added!! ************;
        flg_line=1;
        output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590376#M168961</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2019-09-20T13:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590556#M169037</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/204979"&gt;@KentaMURANAKA&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, ChrisNZ-san:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reply.&lt;/P&gt;
&lt;P&gt;Your idea seems to be good, but you also changed code in PROC REPORT, right?&lt;/P&gt;
&lt;P&gt;if there are duplicate values in Variable COHORT, I want to display only first unique value, so I write code like what I inserted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my previous code, I had already tried your idea, but did not work.&lt;/P&gt;
&lt;P&gt;I have no idea, please help me.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should show explicitly what your expected output would be. Such a create the table manually in the word processor with the values we should get from the example data set. Then there is much less question about what is expected.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 22:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/590556#M169037</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-20T22:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Output Result as Desired Order in RTF?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/591337#M169363</link>
      <description>&lt;P&gt;Hi, ballardw-san:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reply.&lt;/P&gt;&lt;P&gt;I think, in this case, my 1st uploaded code can express all I expected and questioned, so attached nothing supplemental.&lt;/P&gt;&lt;P&gt;But also think, less information and I should have give you more information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 23:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Output-Result-as-Desired-Order-in-RTF/m-p/591337#M169363</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2019-09-24T23:53:27Z</dc:date>
    </item>
  </channel>
</rss>

