BookmarkSubscribeRSS Feed
davis
Fluorite | Level 6

Good afternoon,

 

I have a quick question, and was wondering if someone in the community could help.

 

I am running proc tabulate on some data.  To be sure the code ran as intended, I manually computed a few cells.

 

Attached is a snapshot from proc tabulate, which reports a 3.69 row percent, a numerator of 642,583 and denominator of 16,780,658.

 

As a hedge, I manually computed 642,583 / 16,780,658 and came up with 3.83%.  I ASSUME the following code is incorrect. 

 

Thoughts on the apparent discrepancy?  Thanks.

-----------

proc tabulate

     data=DSN format=comma20.2;

     CLASS STATE        /     ORDER=UNFORMATTED MISSING;

     CLASS Flag1           /     ORDER=UNFORMATTED MISSING;

     CLASS D120_flag   /     ORDER=UNFORMATTED MISSING;

 

     TABLE /* Row Dimension */

           STATE*(

                D120_flag*(

                N

                RowPctN)

                ALL={LABEL="Total (ALL)"}*N)

                ALL={LABEL="Total (ALL)"}*(

                N

                RowPctN

                D120_flag*(

                N

                ColPctN)),

                /* Column Dimension */

           Flag1;

           ;

* freq cur_upb_amt;

run;

;

 

 

2 REPLIES 2
Astounding
PROC Star
One feature that you have to appreciate is that PROC TABULATE automatically removes all observations that have a missing value for any CLASS variable. So any time FLAG1 or STATE or D120_FLAG is missing, PROC TABULATE ignores the observation. That probably accounts for the difference you see.

If you want to change the result, take a look at the MISSING option.
davis
Fluorite | Level 6

Thanks.

 

The coding error has been identified.

 

Row values were not totaled.  So, the denominator used in the calculation was not the 'total'.

 

The calculation makes sense now that this adjustment was made.

 

Manual checks.  What would we do without them.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 583 views
  • 2 likes
  • 2 in conversation