Help using Base SAS procedures

Regading Proc Tabulate

Accepted Solution Solved
Reply
Contributor
Posts: 57
Accepted Solution

Regading Proc Tabulate

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


Accepted Solutions
Solution
‎09-23-2014 09:36 AM
SAS Super FREQ
Posts: 8,743

Re: Regading Proc Tabulate

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


All Replies
Super User
Super User
Posts: 7,401

Re: Regading Proc Tabulate

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.

Solution
‎09-23-2014 09:36 AM
SAS Super FREQ
Posts: 8,743

Re: Regading Proc Tabulate

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;

Contributor
Posts: 57

Re: Regading Proc Tabulate

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 220 views
  • 0 likes
  • 3 in conversation