turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- ODS and Base Reporting
- /
- how to create this report classified by k

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-17-2012 10:29 AM

how to create this report classified by k?

Thanks

data have;

input x y z k $;

cards;

1 2 3 a

1 1 3 a

5 2 3 a

0 3 5 a

3 1 3 b

1 3 3 b

1 3 5 b

0 1 3 b

6 5 3 b

1 0 3 b

4 2 5 a

1 4 3 a

0 1 3 a

;

run;

ods listing close;

ods tagsets.excelxp file='H:\My Documents\total29.xls' style=sasweb

options(default_column_width="5,10,10" )

;

proc report data=have nowd;

column x y z k;

define x/display;

define y/analysis sum;

define z/analysis mean;

define k/group ;/*not work*/

rbreak before/summarize;

run;

ods tagsets.excelxp close;

ods listing;

Accepted Solutions

Solution

04-18-2012
11:03 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to George_S

04-18-2012 11:03 AM

Hi: Take a look at these two reports. Asking for the mean statistic for Z doesn't make sense if you are going to just DISPLAY all the values of X. For example, you have K=A and X=0 for two observations:

**x y z k**

**0 3 5 a**

**0 1 3 a**

So what do you want to see for the MEAN statistic on the Z column the individual values of 5 and 3 or do you want to see one row with 5+3/2????

See attached screen shots -- using your data and different usages for K and X. If you want to show the MEAN only at the break, then that is possible using ORDER usage for K and X; but if you want the MEAN for every unique combination of K and X, then you should have GROUP usage for both K and X.

cynthia

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to George_S

04-17-2012 10:36 AM

Hi,

Try this..

proc report data=have nowd;

column x y z k;

define x/'x';

define y/analysis sum;

define z/analysis mean;

define k/group ;/*not work*/

rbreak before/summarize;

run;

Thanks,

Shiva

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to George_S

04-17-2012 12:15 PM

Hi:

What do you mean when you say, "classified by k" -- does that mean you want to see all the values for 'a' together and then all the values for 'b' together???? Then do you want to see X, Y and Z as totals for each value of K or do you want to see every individual row for K on the report????

Thanks for showing the program, but a bit more info is needed to understand what you want. I'm not sure what your comment "/* not work */" means -- usually, if you want to GROUP on K, you would list it first in the COLUMN statement. As suggested by Shiva, with a usage of DISPLAY for the variable X, you will not get collapsing or totals -- if X is numeric, then taking off the usage of DISPLAY will cause you to get summary numbers for X, Y and Z.

Did you run the modified code? Is it what you anticipated or wanted?

cynthia

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Cynthia_sas

04-17-2012 12:37 PM

Thank you Shivas and Cynthia!

the result of y and z is exact what I want,but x is just for display the original values but not for summation.

proc report data =have

out =want6

nowindows

;

column x y z k new1;

define k / group ;** define x/ display ; /*This will cause problem,I want display all the X a, also I want the sum of y and z by k*/**

define y / analysis sum ;

define z / analysis sum ;

define new1 / computed ;

define new2 / computed ;

compute new1;

new1 = y.sum *k;

endcomp;

rbreak before/summarize;

run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to George_S

04-17-2012 12:51 PM

Hi..

Is this the output you required..

proc report data=have nowd;

column x (y, sum)(z, mean) k;

define x/'x' display;

define y/display;

define z/display;

define k/group ;/*not work*/

rbreak before/summarize;

run;

Thanks,

Shiva

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to George_S

04-17-2012 02:08 PM

Hi:

K is a character variable. I don't understand what you are trying with this statement:

compute new1;

** new1 = y.sum *k;**

endcomp

you can never multiply a number by a character value.

cynthia

Solution

04-18-2012
11:03 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to George_S

04-18-2012 11:03 AM

Hi: Take a look at these two reports. Asking for the mean statistic for Z doesn't make sense if you are going to just DISPLAY all the values of X. For example, you have K=A and X=0 for two observations:

**x y z k**

**0 3 5 a**

**0 1 3 a**

So what do you want to see for the MEAN statistic on the Z column the individual values of 5 and 3 or do you want to see one row with 5+3/2????

See attached screen shots -- using your data and different usages for K and X. If you want to show the MEAN only at the break, then that is possible using ORDER usage for K and X; but if you want the MEAN for every unique combination of K and X, then you should have GROUP usage for both K and X.

cynthia