Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SAS: PROC REPORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1456
Location: Azeroth

PostPosted: Wed Mar 23, 2011 2:52 pm    Post subject: SAS: PROC REPORT
Reply with quote

Hi,

I have an input SAS dataset which looks like, (it has beer sales numbers based on the temperature)

Code:
month    sales    hightemp    lowtemp
                                     
   1     130.2       3.5        -3.2
   2     137.0       6.9         0.8
   3     171.4      11.5         2.9
   4     178.5      13.0         4.7
   5     211.9      16.9         8.6
   6     227.4      19.9        10.3
   7     253.8      22.7        13.0
   8     254.6      22.1        13.2
   9     152.5      19.4        11.5
  10     177.2      13.9         7.1
  11     161.8       8.8         0.8
  12     179.3       8.6         3.1
  13     156.8       3.7        -2.8
  14     130.4       8.4         2.9
  15     166.1       8.8         2.5
  16     205.4      14.2         5.7
  17     209.1      16.0         8.5
  18     235.4      17.8        10.6
  19     227.3      20.7        12.4
  20     203.9      20.3        10.2
  21     182.5      17.5        10.3
  22     200.4      15.0         6.5
  23     161.0       9.8         4.1
  24     195.9       7.1         2.7


I am trying to create a yearly summary report which looks like,

Code:
Year                 Sales                       hightemp         lowtemp

 1    mean of sales from month1-month12     mean of hightemp  mean of low temp
 2    mean of sales from month13-month24    mean of hightemp  mean of low temp



I tried the below code,
I am able to compute 'year' variable values, but I don't know how to GROUP on 'year' variable value which is computed.
Code:
proc report data = xx.sales nowd headline headskip center; 
column month year sales ('-Temperature-' hightemp lowtemp);
define month / analysis noprint;                           
define year / computed 'Year' width = 5;                   
define sales / display    'SALES' width = 5;               
define hightemp / display sum   'Hightemp' width = 8;       
define lowtemp  / display sum   'Lowtemp'  width = 7;       
                                                           
compute year;                                               
if mod(month.sum,12) = 0 and int(month.sum/12) = 0 then     
year = 1;                                                   
else if mod(month.sum,12) = 0 then year = int(month.sum/12);
else year = int(month.sum/12) + 1;                         
endcomp;                                                   
                                                           
run;



Output of above code;
Code:
              ---Temperature---
 Year  SALES  Hightemp  Lowtemp
-------------------------------
                               
    1  130.2       3.5     -3.2
    1    137       6.9      0.8
    1  171.4      11.5      2.9
    1  178.5        13      4.7
    1  211.9      16.9      8.6
    1  227.4      19.9     10.3
    1  253.8      22.7       13
    1  254.6      22.1     13.2
    1  152.5      19.4     11.5
    1  177.2      13.9      7.1
    1  161.8       8.8      0.8
    1  179.3       8.6      3.1
    2  156.8       3.7     -2.8
    2  130.4       8.4      2.9
    2  166.1       8.8      2.5
    2  205.4      14.2      5.7
    2  209.1        16      8.5
    2  235.4      17.8     10.6
    2  227.3      20.7     12.4
    2  203.9      20.3     10.2
    2  182.5      17.5     10.3
    2  200.4        15      6.5
    2    161       9.8      4.1
    2  195.9       7.1      2.7


Please let me know how this can be done using PROC REPORT?
Back to top
View user's profile Send private message

Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Wed Mar 23, 2011 9:20 pm    Post subject:
Reply with quote

Include a BY year; statement in your proc statements.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed Mar 23, 2011 9:46 pm    Post subject:
Reply with quote

Calculate YEAR before the PROC REPORT and get rid of the COMPUTE CODE. Instead use
Code:
proc report data = sales nowd headline headskip center;
column       year sales ('-Temperature-' hightemp lowtemp) ;
define year     / group    'Year' width = 5;
define sales    / analysis mean  'SALES'    width = 5;
define hightemp / analysis mean  'Hightemp' width = 8;
define lowtemp  / analysis mean  'Lowtemp'  width = 7;
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Mar 24, 2011 2:47 pm    Post subject:
Reply with quote

Maybe you could use "PROC MEANS" in stead of "PROC REPORT"
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1456
Location: Azeroth

PostPosted: Thu Mar 24, 2011 9:46 pm    Post subject:
Reply with quote

Hi,

Thanks for the suggestions.
As Robert said i removed the years variable and the output was correct.

used proc format to replace month variable,

Code:
proc format;
value years. 1-12 = 1
          13-24=2
          25-36=3
                  .
                  .
; run;

define month / display 'Year' format=years.;


Quote:
Maybe you could use "PROC MEANS" in stead of "PROC REPORT"

This was a self learning exercise on proc report, i still have not learnt using proc means yet. have to

Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Thu Mar 24, 2011 10:51 pm    Post subject:
Reply with quote

Glad to hear it's working.

PROC MEANS is nice but PROC UNIVARIATE gives you more information for the same effort!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Detailed Transaction History report f... Kyle Carroll CICS 5 Tue Oct 18, 2016 12:42 am
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am
No new posts Daily report to be extracted from CA ... polymathtarun DFSORT/ICETOOL 5 Mon Jul 11, 2016 4:33 pm
No new posts Report view in Mobile devices Robert Sample All Other Mainframe Topics 0 Thu Jun 23, 2016 7:05 pm
No new posts COBOL Report view in Mobile devices balaji81_k COBOL Programming 4 Thu Jun 23, 2016 6:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us