Conditional Aggregate within Aggregate?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional Aggregate within Aggregate?

DKUKEC
Dear Listers,

Sorry, however, I am having little luck figuring out the following - after reviewing FM and WWW.  I would like to use the following syntax to create new vars by aggregating; however, I would also like to add/create a new var with a conditional aggregate within the following syntax;

when OUTCOME=1.
Aggregate /S_EXITS=SUM (ENDDAY).

Typically, I would use the TEMPORARY. SELECT IF OUTCOME=1 syntax; however, if I do this the condition would apply to all of the aggregate vars... I would like to aggregate the vars below without the condition.  What is the best approach to computing the var S_EXITS.  Any suggested syntax or references is greatly appreciated.

USE ALL.
*DATASET DECLARE ADPREPORT .
AGGREGATE
  /OUTFILE='ADPREPORT'
  /BREAK=YEAR MONTH
  /ADMISSIONS=SUM (STARTDAY)
  /EXITS=SUM (ENDDAY)
  /CENSUSDAYS=N.

Cheers,
Damir

Reply | Threaded
Open this post in threaded view
|

Re: Conditional Aggregate within Aggregate?

David Marso
Administrator
I would simply do this:
Before the AGGREGATE.

IF (OUTCOME EQ 1) S_EX=ENDDAY.
then add to the aggregate command:
/S_EXITS=SUM ( S_EX)

AGGREGATE
  /OUTFILE='ADPREPORT'
  /BREAK=YEAR MONTH
  /ADMISSIONS=SUM (STARTDAY)
  /EXITS=SUM (ENDDAY)
  /S_EXITS=SUM ( S_EX)
  /CENSUSDAYS=N.

What do you have the DATASET DECLARE commented out and then quoted in the agg command?
That doesn't make a lot of sense?

DKUKEC wrote
Dear Listers,

Sorry, however, I am having little luck figuring out the following - after reviewing FM and WWW.  I would like to use the following syntax to create new vars by aggregating; however, I would also like to add/create a new var with a conditional aggregate within the following syntax;

when OUTCOME=1.
Aggregate /S_EXITS=SUM (ENDDAY).

Typically, I would use the TEMPORARY. SELECT IF OUTCOME=1 syntax; however, if I do this the condition would apply to all of the aggregate vars... I would like to aggregate the vars below without the condition.  What is the best approach to computing the var S_EXITS.  Any suggested syntax or references is greatly appreciated.

USE ALL.
*DATASET DECLARE ADPREPORT .
AGGREGATE
  /OUTFILE='ADPREPORT'
  /BREAK=YEAR MONTH
  /ADMISSIONS=SUM (STARTDAY)
  /EXITS=SUM (ENDDAY)
  /CENSUSDAYS=N.

Cheers,
Damir
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Conditional Aggregate within Aggregate?

DKUKEC
Thank you David.

Your solution worked.  The * was a typo.

Cheers,
Damir