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
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;
rateord = readmit_numer.sum/readmit_denom.sum;
ods listing close;
12-20-2012 12:23 AM
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.
Need further help from the community? Please ask a new question.