Skip to content
Advertisement

proc sql: calculate multiple summary stats based on different conditions in one step

I want to calculate two averages, one over rows before a certain date, and the other after a certain date, using proc SQL in SAS. Currently, I’m doing this in two steps and then merge. Is there a way to do this in one step? Thank you.

Advertisement

Answer

Using the fact that SAS represents true by 1 and false by 0:

gives the same result as your code.

Note that this is probably wrong, because you neglect the cases where cal_date = fdate.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement