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

Dear Friends,

Here i need results like village wise and year wise total and percentage. but i am trying with the below code but it not works. Please help me in this.

proc tabulate data=paper.Role_gender_in_;

class Village  year Activity_Name  men Women both;

tables  (Village *  year * Activity_Name),  Women (n colpctn) /printmiss misstext=' ' ;

format Women AWM_.;

run; bula

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi, your TABULATE statement is missing a table operator. So, this specification: Women(n colpctn) is incorrect. Usually, one would expect to see Women*(n colpctn); Take a look at the output from this example, I added the ALL to show you the COLPCTN was working.

Cynthia

ods html file='c:\temp\example_tab.html';

proc tabulate data=sashelp.prdsale;

class product  year region   prodtype ;

tables  (product *  year * region) all, 

        prodtype *(n colpctn) /printmiss misstext=' ' ;

run;

ods html close;

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

TBH I don't use proc tabulate, so maybe someone who does can help you there.  For this type of thing I would just go directly to an output dataset of (and note you have not provided test data or required output so guessing):

proc sql;

  create table WANT as

  select  AGE,

          SEX,

          COUNT(SEX) as TOT,

          (COUNT(SEX) / (select COUNT(*) from SASHELP.CLASS)) * 100 as PCENT

  from    SASHELP.CLASS

  group by AGE,

           SEX;

quit;

Then use proc report to generate some nice output.

Cynthia_sas
Diamond | Level 26

Hi, your TABULATE statement is missing a table operator. So, this specification: Women(n colpctn) is incorrect. Usually, one would expect to see Women*(n colpctn); Take a look at the output from this example, I added the ALL to show you the COLPCTN was working.

Cynthia

ods html file='c:\temp\example_tab.html';

proc tabulate data=sashelp.prdsale;

class product  year region   prodtype ;

tables  (product *  year * region) all, 

        prodtype *(n colpctn) /printmiss misstext=' ' ;

run;

ods html close;

anilgvdbm
Quartz | Level 8

Dear Cynthia,

Suppose in your example i need subtotal and percentage for product wise how to go with that code?

can you explain to me please that is what exactly i was looking.

Thanks and Regards,

Anil

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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