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
- /
- Base SAS Programming
- /
- Median in sas 9.3

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

01-04-2018 03:57 AM - last edited on 01-04-2018 11:30 AM by Reeza

Dear all,

I have created a ODS excel report with proc report, I have noticed in one of the excel outputs that one table should be reflecting the Median values instead of sum.. I tried changing this in the proc report statement:

define Numbers/group __median__ style={tagattr='format:#,###'} center; /** changed sum to median**/ but it doesnt work.

I tried changing in the base data set in sas using proc sql query, still no use.

Request you to kindly suggest any syntax or anything.I am using SAS 9.3 currently..

Many thanks.

Accepted Solutions

Solution

02-13-2018
11:38 PM

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

Posted in reply to Reeza

02-13-2018 11:38 PM

I have ungrouped my sas dataset and used it again for median under ODS proc reports, and it is working now.

All Replies

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

Posted in reply to don21

01-04-2018 04:06 AM

Its generally not a good idea to do processing in proc report, as that is a reporting function. Use proc means before that to get the data in the way you want then a simple proc report to output the data. Don't think report can even do the more complicated calculations.

proc means data=yourdata; by id; var thevar; output out=want median=median; run;

Shows and example use of proc means (as you haven't shown any test data or code this is just an example).

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

Posted in reply to don21

01-04-2018 04:07 AM

You can use statistics only on *analysis* variables. See the documentation for this:

statistic

associates a statistic with an **analysis** variable. You must associate a statistic with every analysis variable in its definition. PROC REPORT uses the statistic that you specify to calculate values for the analysis variable for the observations that are represented by each cell of the report. **You cannot use statistic in the definition of any other type of variable**.

(emphasize by me)

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

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

Posted in reply to don21

01-04-2018 11:27 AM

ODS EXCEL isn't supported in SAS 9.3

Are you using ODS TAGSETS.EXCELXP or something else?

don21 wrote:

Dear all,

I have created a ODS excel report with proc report, I have noticed in one of the excel outputs that one table should be reflecting the Median values instead of sum.. I tried changing this in the proc report statement:

define Numbers/group

medianstyle={tagattr='format:#,###'} center; /** changed sum to median**/ but it doesnt work.

I tried changing in the base data set in sas using proc sql query, still no use.

Request you to kindly suggest any syntax or anything.I am using SAS 9.3 currently..

Many thanks.

Solution

02-13-2018
11:38 PM

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

Posted in reply to Reeza

02-13-2018 11:38 PM