BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8


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;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

I can replicate your ERRO .

Just remove this statement.

define n/ analysis center;



or code like

define n/ center;

View solution in original post

4 REPLIES 4
robertrao
Quartz | Level 8

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???

Ksharp
Super User

I can replicate your ERRO .

Just remove this statement.

define n/ analysis center;



or code like

define n/ center;

robertrao
Quartz | Level 8

Thanks a lot.. It WORKS But

I dint understand the meaning of:

I can replicate your ERRO .

Regards

Cynthia_sas
SAS Super FREQ

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


error_on_n.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1085 views
  • 1 like
  • 3 in conversation