## Define statement

Solved
Super Contributor
Posts: 1,041

# Define statement

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_);
define trplcd /group;
define new_description/group ;
define n/ analysis center;
define rateord/computed;

endcomp;

compute rateord;

endcomp;
run;
ods listing close;

Accepted Solutions
Solution
‎12-19-2012 11:51 PM
Super User
Posts: 10,787

## Re: Define statement

I can replicate your ERRO .

Just remove this statement.

define n/ analysis center;

or code like

define n/ center;

All Replies
Super Contributor
Posts: 1,041

## Re: Define statement

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
Super User
Posts: 10,787

## Re: Define statement

I can replicate your ERRO .

Just remove this statement.

define n/ analysis center;

or code like

define n/ center;

Super Contributor
Posts: 1,041

## Re: Define statement

Thanks a lot.. It WORKS But

I dint understand the meaning of:

I can replicate your ERRO .

Regards

SAS Super FREQ
Posts: 9,371

## Re: Define statement

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

🔒 This topic is solved and locked.