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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 1029 views
  • 2 likes
  • 2 in conversation