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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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