BookmarkSubscribeRSS Feed
shudsoo
Calcite | Level 5

Hi,

Newbie to the SAS DI world and working with Summary Statistics to return sums, mean and median for a given group of data. I need to calculate the summary stats which works fine and group by two separate variables - FYear and DIAG but then also include 2 additional columns against the DIAG code for description and gender - I have put these into the ID statement to return as additional columns in the output table but the summary stats table that is returned puts a description against the total row - _WAY  = 0 and _TYPE  = 0 that has nothing to do with that row.

For example - the _WAY  = 0 and _TYPE = 0 total row should have no entry in the DIAG column or the Description column as this contains the totals for the rest of the variables but when I run the query in SAS DI - it returns a description into the top total row that has nothing to do with the total.

Interestingly, the value that it returns is the description that is the last alphabetical one from the main list of DIAG description.

Any advice would be helpful.

Thanks

Steve

1 REPLY 1
Astounding
PROC Star

Steve,

It sounds like the ID statement is working like it should.  Here's what it does.

For every record in the summarized output, the ID variables should be copied from a single observation that went into computing that summary record.  Which observation's ID statements get used?  As you noted, there is an element of "maximum value" in making the selection.  With a single ID variable, it is the maximum value.  With 2 ID variables, it is the maximum value of the first variable, but not necessarily the maximum value of the second variable.  Since the rule is to take both ID variables from a single observation, "maximum" means take the maximum value of the first ID variable.  For all those observations having the maximum value of the first ID variable, take the maximum value of the second ID variable.

The only choice you have is that you are allowed to switch to "minimum" instead of "maximum".  But the basic rule stays in place:  all ID variables come from a single observation that went into computing statistics for the summary row.

Good luck.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 762 views
  • 3 likes
  • 2 in conversation