Help using Base SAS procedures

Aggregate sum of all observations decreases when I add variables to class statement. Why?

Reply
Contributor
Posts: 30

Aggregate sum of all observations decreases when I add variables to class statement. Why?

Why would the difference between these two pieces of code cause the aggregate sum of all observations' mmos to be different?

I understand that we shouldn't expect the observations to individually be the same, but shouldn't the aggregate totals be?s

proc summary noprint missing nway data=v_mmr_&state;

Class inc_year lob plan_number SCC tin tin_nm_rllp stat;

Var mmos_:;

output out=mmrsum_&state (drop=_type_ _freq_) sum=;

quit;


proc summary noprint missing nway data=v_mmr_&state;

Class inc_year lob plan_number SCC tin tin_nm_rllp stat current_ctg yearmo;

Var mmos_:;

output out=mmrsum_&state (drop=_type_ _freq_) sum=;

quit;

Super User
Posts: 5,075

Re: Aggregate sum of all observations decreases when I add variables to class statement. Why?

The totals should be the same, sort of.  A couple of related questions, though:

How different are they?

How many observations are there in each output data set?

Since you're already using the MISSING option, I would suspect this is a matter of floating point arithmetic.  Adding up imprecisely stored sets of values should get very nearly (but not necessarily exactly) the same total.

Good luck.

N/A
Posts: 1

Re: Aggregate sum of all observations decreases when I add variables to class statement. Why?

Do you have missing values in current_ctg and/or yearmo?

Contributor
Posts: 30

Re: Aggregate sum of all observations decreases when I add variables to class statement. Why?

So I think the issue is that when I tried to compare the two datasets in Excel, the first dataset is small enough for Excel but the second one isn't.

When I compare them in SAS they end up being the same.

Ask a Question
Discussion stats
  • 3 replies
  • 396 views
  • 0 likes
  • 3 in conversation