BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasuser34
Calcite | Level 5

I am using proc tabulate to create a table like the one below.

 

percenttotal.PNG

 

It is intended to count the number of observations for each hospital location by year. Additionally, I would like to generate column percentages for each year's observations. 

 

I was able to create my desired layout, but my column percentage totals are coming out to 0%. They should be 100%. I can't seem to figure out what has happened with my nesting to cause this error. Any assistance would be greatly appreciated!

 

 

This is the code that I am using:

 

proc tabulate data=mydata ;
            CLASS location specdateYR/ PRELOADFMT order=data;
            CLASSLEV location specdateYR/ S=[background=bigb foreground=white];
            TABLE location = ' ' (ALL = {label='Total' S=[background=bigb foreground=white]}),
                         (specdateYR = ' ' (All= {label='Total' S=[background=bigb foreground=white]})) 
                         *((N= {label='N Events' S=[background=bigb foreground=white]}) 
                           ((colpctn= {label='% Events' S=[background=bigb foreground=white]})*f=pctfmt.)) 
                           /misstext='0' BOX=[label='Events By Year and Location*' S=[background=bigb foreground=white]];
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Show the definitions of your PCTFMT. Likely you didn't allocate the correct options to show 100.00%.

View solution in original post

3 REPLIES 3
Reeza
Super User

Remove the format and are they still 0?

ballardw
Super User

Show the definitions of your PCTFMT. Likely you didn't allocate the correct options to show 100.00%.

sasuser34
Calcite | Level 5

 

This is the format I was using. 

 

proc format;
picture pctfmt (round) other='09.99%';
run;

 

I realized that my format did not allow for 3 digits. I changed the format to 

 

proc format;
picture pctfmt (round) other='009.99%';
run;

 

which corrected the issue. 

 

Thank you for pointing me in the right direction!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 3 replies
  • 845 views
  • 0 likes
  • 3 in conversation