<?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-question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-question/m-p/480367#M124145</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to use proc report.&lt;/P&gt;&lt;P&gt;I want to&amp;nbsp;have 7 fields in required report.&lt;/P&gt;&lt;P&gt;required fields are:&lt;/P&gt;&lt;P&gt;TEAM&lt;BR /&gt;Number of customers in 1806&lt;BR /&gt;Sum of Y in 1806&lt;BR /&gt;Difference of Sum of Y between 1806 and 1805&lt;BR /&gt;PCT difference of Sum of Y between 1806 and 1805&lt;BR /&gt;Difference of Sum of Y between 1806 and 1712&lt;BR /&gt;PCT difference of Sum of Y between 1806 and 1712&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I am getting also fields that I don't want (because of using across...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA tbl1;
input ID  mon Team $ Y;
cards;
1  1806  a 10
2  1806  a 11
3  1806  b 12
4  1806  a 13
5  1806  b 14
6  1806  b 15
7  1806  a 16

1  1805  a 10
2  1805  a 11
3  1805  b 12
4  1805  b 13
5  1805  a 14
1  1712  a 8
2  1712  a 9
3  1712  b 10
5  1712  b 11
6  1712  a 12
7  1712  a 13
;
run;


Proc report data=tbl1;
   columns Team mon,(Y=Yn  Y=Ysum ) 
			 ('Comparison to previous month' diff_Y_From_PrevMon    PCT_diff_Y_From_PrevMon)
			('Comparison to last DEC' diff_Y_From_LastDEC   PCT_diff_Y_From_LastDEC)
;
   define Team/ group  order=data  'Team';
   define mon/across order=data  'Month';
   define Yn / n 'Customers'  format=comma12. ;
   define Ysum / sum 'SUM_Y' format=comma12.;

  define diff_Y_From_PrevMon/ computed  'differnce_Y';
			   compute diff_Y_From_PrevMon;
			      diff_Y_From_PrevMon =_c3_-_c5_;
			   endcomp ;
 define PCT_diff_Y_From_PrevMon/ computed  format=percentn9.1  'PCT_differnce_Y';
			   compute PCT_diff_Y_From_PrevMon;
			      PCT_diff_Y_From_PrevMon =(_c3_-_c5_)/_c5_;
			   endcomp ;

  define diff_Y_From_LastDEC/ computed  'differnce_Y';
			   compute diff_Y_From_LastDEC;
			      diff_Y_From_LastDEC =_c3_-_c7_;
			   endcomp ;
 define PCT_diff_Y_From_LastDEC/ computed  format=percentn9.1  'PCT_differnce_Y';
			   compute PCT_diff_Y_From_LastDEC;
			      PCT_diff_Y_From_LastDEC =(_c3_-_c7_)/_c7_;
			   endcomp ;
rbreak after/ summarize;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA tbl1;&lt;BR /&gt;input ID mon Team $ Y;&lt;BR /&gt;cards;&lt;BR /&gt;1 1806 a&lt;BR /&gt;2 1806 a&lt;BR /&gt;3 1806 b&lt;BR /&gt;4 1806 a&lt;BR /&gt;1 1805 a&lt;BR /&gt;2 1805 a&lt;BR /&gt;3 1805 c&lt;BR /&gt;4 1805 b&lt;BR /&gt;5 1805 a&lt;BR /&gt;1 1712 a&lt;BR /&gt;2 1712 a&lt;BR /&gt;3 1712 c&lt;BR /&gt;5 1712 c&lt;BR /&gt;6 1712 a&lt;BR /&gt;7 1712 a&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jul 2018 09:00:54 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-07-23T09:00:54Z</dc:date>
    <item>
      <title>PROC REPORT-question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-question/m-p/480367#M124145</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to use proc report.&lt;/P&gt;&lt;P&gt;I want to&amp;nbsp;have 7 fields in required report.&lt;/P&gt;&lt;P&gt;required fields are:&lt;/P&gt;&lt;P&gt;TEAM&lt;BR /&gt;Number of customers in 1806&lt;BR /&gt;Sum of Y in 1806&lt;BR /&gt;Difference of Sum of Y between 1806 and 1805&lt;BR /&gt;PCT difference of Sum of Y between 1806 and 1805&lt;BR /&gt;Difference of Sum of Y between 1806 and 1712&lt;BR /&gt;PCT difference of Sum of Y between 1806 and 1712&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I am getting also fields that I don't want (because of using across...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA tbl1;
input ID  mon Team $ Y;
cards;
1  1806  a 10
2  1806  a 11
3  1806  b 12
4  1806  a 13
5  1806  b 14
6  1806  b 15
7  1806  a 16

1  1805  a 10
2  1805  a 11
3  1805  b 12
4  1805  b 13
5  1805  a 14
1  1712  a 8
2  1712  a 9
3  1712  b 10
5  1712  b 11
6  1712  a 12
7  1712  a 13
;
run;


Proc report data=tbl1;
   columns Team mon,(Y=Yn  Y=Ysum ) 
			 ('Comparison to previous month' diff_Y_From_PrevMon    PCT_diff_Y_From_PrevMon)
			('Comparison to last DEC' diff_Y_From_LastDEC   PCT_diff_Y_From_LastDEC)
;
   define Team/ group  order=data  'Team';
   define mon/across order=data  'Month';
   define Yn / n 'Customers'  format=comma12. ;
   define Ysum / sum 'SUM_Y' format=comma12.;

  define diff_Y_From_PrevMon/ computed  'differnce_Y';
			   compute diff_Y_From_PrevMon;
			      diff_Y_From_PrevMon =_c3_-_c5_;
			   endcomp ;
 define PCT_diff_Y_From_PrevMon/ computed  format=percentn9.1  'PCT_differnce_Y';
			   compute PCT_diff_Y_From_PrevMon;
			      PCT_diff_Y_From_PrevMon =(_c3_-_c5_)/_c5_;
			   endcomp ;

  define diff_Y_From_LastDEC/ computed  'differnce_Y';
			   compute diff_Y_From_LastDEC;
			      diff_Y_From_LastDEC =_c3_-_c7_;
			   endcomp ;
 define PCT_diff_Y_From_LastDEC/ computed  format=percentn9.1  'PCT_differnce_Y';
			   compute PCT_diff_Y_From_LastDEC;
			      PCT_diff_Y_From_LastDEC =(_c3_-_c7_)/_c7_;
			   endcomp ;
rbreak after/ summarize;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA tbl1;&lt;BR /&gt;input ID mon Team $ Y;&lt;BR /&gt;cards;&lt;BR /&gt;1 1806 a&lt;BR /&gt;2 1806 a&lt;BR /&gt;3 1806 b&lt;BR /&gt;4 1806 a&lt;BR /&gt;1 1805 a&lt;BR /&gt;2 1805 a&lt;BR /&gt;3 1805 c&lt;BR /&gt;4 1805 b&lt;BR /&gt;5 1805 a&lt;BR /&gt;1 1712 a&lt;BR /&gt;2 1712 a&lt;BR /&gt;3 1712 c&lt;BR /&gt;5 1712 c&lt;BR /&gt;6 1712 a&lt;BR /&gt;7 1712 a&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 09:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-question/m-p/480367#M124145</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-07-23T09:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT-question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-question/m-p/480370#M124146</link>
      <description>&lt;P&gt;Use a procedure or datastep which is designed to do statistics - means, summary etc.&amp;nbsp; Then report your data out.&amp;nbsp; I have never seen doing calculations in a reporting procedure to yield a good process.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 09:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-question/m-p/480370#M124146</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-23T09:29:58Z</dc:date>
    </item>
  </channel>
</rss>

