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
- /
- Define statement

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-19-2012 10:59 PM

This code is from proc report step before the sorting step.

I have around 20thousand observations in the dataset list_subset_merge2;

trplcd (DRG code) is used to group(condense) those observation into approx 700 in the report.

I want the number of observations(which is 20thousand)....

i use define n

IT SAYS N DOES NOT EXIST IN THE INCOMING DATASET

ods listing;

proc report data=list_subset_merge2 nowindows MISSING out=rate_calculation(drop=_break_);

columns rateord trplcd new_description **n** ('Readmission Rates' Readmit_Numer Readmit_Denom Readmit);

define trplcd /group;

define new_description/group ;**define n/ analysis center;**

define Readmit_Numer/sum;

define Readmit_Denom/sum;

define Readmit/computed;

define rateord/computed;

compute readmit;

readmit=readmit_numer.sum/readmit_denom.sum;

endcomp;

compute rateord;

rateord = readmit_numer.sum/readmit_denom.sum;

endcomp;

run;

ods listing close;

Accepted Solutions

Solution

12-19-2012
11:51 PM

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

Posted in reply to robertrao

12-19-2012 11:51 PM

I can replicate your ERRO .

Just remove this statement.

**define n/ analysis center;**

**or code like **

**define n/ center;**

All Replies

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

Posted in reply to robertrao

12-19-2012 11:08 PM

I was thinking n as a statistic would give the number of observations per each TRPLCD

and i can summarize all of them at the very bottom???

Solution

12-19-2012
11:51 PM

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

Posted in reply to robertrao

12-19-2012 11:51 PM

I can replicate your ERRO .

Just remove this statement.

**define n/ analysis center;**

**or code like **

**define n/ center;**

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

Posted in reply to Ksharp

12-19-2012 11:59 PM

Thanks a lot.. It WORKS But

I dint understand the meaning of:

I can replicate your ERRO .

Regards

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

Posted in reply to robertrao

12-20-2012 12:23 AM

Hi:

Look at the attached screenshot. ANALYSIS as a USAGE option for N tells PROC REPORT that you have a DATASET variable, named N, that you want to have treated as an ANALYSIS variable and you are asking for the SUM statistic by default. It doesn't matter that you do not have the statistic "SUM", asking for ANALYSIS tells PROC REPORT that N is a DATASET variable. There is an ERROR after the first step because the variable N is NOT in SASHELP.CLASS. This first program seems to be the equivalent of what you did in your program.

If you want to get the N **statistic**, then do NOT use the usage of ANALYSIS. Do not use a USAGE at all. See the 2 different programs in the LOG. Without a usage of ANALYSIS, SAS treats N as the N statistic. On the other hand, you need either ANALYSIS MEAN or just MEAN on the DEFINE statements for HEIGHT and WEIGHT so that PROC REPORT knows how you want to use those variables and which statistic you want to generate. As a rule of thumb, I try to avoid having variables named the same as the keyword statistics. But PROC REPORT tried to do what you told it to do -- and when it didn't find a variable called N in the dataset, it gave an ERROR message.

Understanding USAGE options is critical to working with PROC REPORT successfully.

cynthia