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
SAS Super FREQ

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
SAS Super FREQ

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

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