<?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 Proc report define statement order options output problems in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705576#M24750</link>
    <description>&lt;P&gt;Hi, I have some problems about Proc report outputs. I want to use ORDER option to suppress some repetitive values, but got a unexpected output. Here's my codes:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x1;
informat subject armcd period $20.;
input subject armcd period;
cards;
C007 RT 2
C007 RT 2
C010 RT 1
C010 RT 1
C010 RT 1
C010 RT 1
C010 RT 2
C010 RT 2
C010 RT 2
C010 RT 2
C010 RT 2
;
proc sort;
by subject armcd period;
run;

proc report data=x1;
column subject armcd period;
define subject/order order=data;
define armcd/order order=data;
define period/order order=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I thought the output would be:&lt;/P&gt;&lt;PRE&gt;C007 RT 2

C010 RT 1



        2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;I was surprised I got:&lt;/P&gt;&lt;PRE&gt;C007 RT 2 
      
C010 RT 2 
      
      
      
      
        1 
      
      
      &lt;/PRE&gt;&lt;P&gt;So, why the output would be like this?Why the value "1" is showing below the value "2"?Could someone explain to me?&amp;nbsp;&lt;SPAN&gt;Any&amp;nbsp;help will be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Dec 2020 03:56:47 GMT</pubDate>
    <dc:creator>Maplefin</dc:creator>
    <dc:date>2020-12-14T03:56:47Z</dc:date>
    <item>
      <title>Proc report define statement order options output problems</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705576#M24750</link>
      <description>&lt;P&gt;Hi, I have some problems about Proc report outputs. I want to use ORDER option to suppress some repetitive values, but got a unexpected output. Here's my codes:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x1;
informat subject armcd period $20.;
input subject armcd period;
cards;
C007 RT 2
C007 RT 2
C010 RT 1
C010 RT 1
C010 RT 1
C010 RT 1
C010 RT 2
C010 RT 2
C010 RT 2
C010 RT 2
C010 RT 2
;
proc sort;
by subject armcd period;
run;

proc report data=x1;
column subject armcd period;
define subject/order order=data;
define armcd/order order=data;
define period/order order=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I thought the output would be:&lt;/P&gt;&lt;PRE&gt;C007 RT 2

C010 RT 1



        2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;I was surprised I got:&lt;/P&gt;&lt;PRE&gt;C007 RT 2 
      
C010 RT 2 
      
      
      
      
        1 
      
      
      &lt;/PRE&gt;&lt;P&gt;So, why the output would be like this?Why the value "1" is showing below the value "2"?Could someone explain to me?&amp;nbsp;&lt;SPAN&gt;Any&amp;nbsp;help will be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 03:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705576#M24750</guid>
      <dc:creator>Maplefin</dc:creator>
      <dc:date>2020-12-14T03:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report define statement order options output problems</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705597#M24751</link>
      <description>&lt;P&gt;I very rarely use proc report.&amp;nbsp; But while I believe "order=data" means to report data in the order it is encountered, it's a global concept, not a "within group" concept.&amp;nbsp; Since the first value of period encountered (for C007 RT) is a 2, it is first reported not only for C007 Rt, but also for subsequent subject/armcd combinations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can test this by changing the PERIOD from 2 to 1 for first (or both) C007 RT record(s).&amp;nbsp; Then you will see period 1 preceding period 2 for C010 RT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can fix this by specifying ORDER=INTERNAL&amp;nbsp; (the internal numeric values) for PERIOD.&amp;nbsp; Perhaps that's what you really want.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 06:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705597#M24751</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-14T06:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report define statement order options output problems</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705659#M24752</link>
      <description>&lt;P&gt;you used order=DATA .&lt;/P&gt;
&lt;P&gt;Try order=internal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data=x1 nowd;
column subject armcd period;
define subject/order order=data;
define armcd/order order=data;
define period/order &lt;STRONG&gt;order=internal&lt;/STRONG&gt;;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Dec 2020 12:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705659#M24752</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-12-14T12:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report define statement order options output problems</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705708#M24753</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If you change period to be numeric and create a fake "order" variable that is the obs number and then use SPANROWS, you will see that SPANROWS puts all of subject C007 into one ordered group and then C010 into another ordered group, You really do not need to overcontrol the order, it seems to come out fine if you don't use either order=data or order=internal. At any rate, I used ORDVAR for this first output, but I ran 3 tests and except for ORDVAR in the first report, the ordering of the other reports was the same, whether period was characer or numeric. So you can see the side effect of using ORDER as the usage for subject and armcd and where the groups and subgroups are by using SPANROWS:&lt;/P&gt;
&lt;DIV id="tinyMceEditorCynthia_sas_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorCynthia_sas_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="armcd.png" style="width: 250px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52592i0C3455B67C6628C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="armcd.png" alt="armcd.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here's what I changed to create the above output:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;data x1;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;* period is numeric, cper is character;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;length subject armcd $20 cper $2;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;input subject armcd period;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ordvar = _n_;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;cper = put(period,2.);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;cards;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C007 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C007 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;C010 RT 2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;proc sort data=x1;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;by subject armcd period;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;proc report data=x1 &lt;FONT color="#FF00FF"&gt;spanrows&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;title '1 No order specified, with ORDVAR';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;column subject armcd period &lt;FONT color="#FF00FF"&gt;ordvar&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define subject/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define armcd/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define period/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define ordvar / display;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;proc report data=x1 &lt;FONT color="#FF00FF"&gt;spanrows&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;title '2 no order = option specified not using ordvar';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;column subject armcd period ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define subject/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define armcd/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define period/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;title;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;proc report data=x1 &lt;FONT color="#FF00FF"&gt;spanrows&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;title '3 character var cper for period';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;column subject armcd cper ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define subject/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define armcd/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;define cper/order ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;title;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;and here's the output from #2 and #3 basically the same without using any ORDER = option:&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorCynthia_sas_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Hope this helps,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Cynthia&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/705708#M24753</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-12-14T14:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report define statement order options output problems</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/706194#M24757</link>
      <description>&lt;P&gt;Thanks a lot! I tried using ORDER=INTERNAL option and it works. I got the result I want. I think you're right that ORDER option is a global option and not "within-group". I thought ORDER option similar to PROC SORT before. When applying to multiple variables, there are priorities. In PROC SORT procedure, if we specify multiple variables, first sort A, then B and so on. So I thought ORDER option would work like this, first suppress repetitive values of ARMCD, then suppress repetitive SUBJID within suppressed ARMCD, then PERIOD. But it doesn't seem to be like this. I'm wondering how to specify ORDER option to get the output sorted same as my dataset and suppress repetitive values meanwhile.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 02:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/706194#M24757</guid>
      <dc:creator>Maplefin</dc:creator>
      <dc:date>2020-12-16T02:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report define statement order options output problems</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/706199#M24758</link>
      <description>&lt;P&gt;Thanks a lot! I tried not specifying ORDER option, just let SAS choose the default option and got the right result. The default for ORDER option is ORDER=FORMATTED? But in another case, I have some observations, and the values of ARMCD are "TR". I want to let values "TR" show above "RT". Though I sort the datasets by descending armcd, and if I don't specify the value for ORDER= option, I get the unwanted output that values "RT" show above "TR". I just want to get the output sorted same as my origin dataset with suppressed repetitive values.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 03:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-define-statement-order-options-output-problems/m-p/706199#M24758</guid>
      <dc:creator>Maplefin</dc:creator>
      <dc:date>2020-12-16T03:21:51Z</dc:date>
    </item>
  </channel>
</rss>

