Help using Base SAS procedures

Proc tabulate and pctsum

Accepted Solution Solved
Reply
Super Contributor
Posts: 292
Accepted Solution

Proc tabulate and pctsum

I have the following table statement:

table month * (GQBProduct all) , (sale_wt dispwt) * (sum pctsum <sale_wt>) ;

It works as it should but it's not quite what I want.  How do I rewrite the statement such that it displays sale_wt, dispwt and the pctsum for dispwt/sale_wt but not the pctsum of the sale_wt/sale_wt (which is always 100%)?

Thanks,

Bill


Accepted Solutions
Solution
‎02-25-2013 05:03 PM
SAS Super FREQ
Posts: 8,868

Re: Proc tabulate and pctsum

Hi,

The easiest thing to do is change your parentheses so that you get a different keyword statistic (SUM?) used for sale_wt and disp_wt and then just use your PCTSUM<SALE_WT> with DISPWT, as shown in #2 below. I had to make some fake data, so the numbers are probably a bit wonky because of the variables I used as "stand-ins" for SALE_WT and DISPWT.

cynthia

** make some fake data;
data testit;
  set sashelp.prdsale;
  ** only get 3 months;
  where quarter = 1;
  gqbproduct = prodtype;
  sale_wt = actual/100;
  dispwt = predict/100;
run;

    

ods html file='c:\temp\tab_examp.html' style=sasweb;
proc tabulate data=testit;
  class gqbproduct month;
  var sale_wt dispwt;
  table month * (GQBProduct all) ,
        (sale_wt dispwt) * (sum pctsum <sale_wt>)
    /box='1) Original code';
         
  table month * (GQBProduct all) ,
        (sale_wt dispwt)*sum dispwt*(pctsum <sale_wt>)
    /box='2) Changed Code';
run;
ods html close;

View solution in original post


All Replies
Solution
‎02-25-2013 05:03 PM
SAS Super FREQ
Posts: 8,868

Re: Proc tabulate and pctsum

Hi,

The easiest thing to do is change your parentheses so that you get a different keyword statistic (SUM?) used for sale_wt and disp_wt and then just use your PCTSUM<SALE_WT> with DISPWT, as shown in #2 below. I had to make some fake data, so the numbers are probably a bit wonky because of the variables I used as "stand-ins" for SALE_WT and DISPWT.

cynthia

** make some fake data;
data testit;
  set sashelp.prdsale;
  ** only get 3 months;
  where quarter = 1;
  gqbproduct = prodtype;
  sale_wt = actual/100;
  dispwt = predict/100;
run;

    

ods html file='c:\temp\tab_examp.html' style=sasweb;
proc tabulate data=testit;
  class gqbproduct month;
  var sale_wt dispwt;
  table month * (GQBProduct all) ,
        (sale_wt dispwt) * (sum pctsum <sale_wt>)
    /box='1) Original code';
         
  table month * (GQBProduct all) ,
        (sale_wt dispwt)*sum dispwt*(pctsum <sale_wt>)
    /box='2) Changed Code';
run;
ods html close;

Super Contributor
Posts: 292

Re: Proc tabulate and pctsum

Posted in reply to Cynthia_sas

Thank you Cynthia!

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 232 views
  • 1 like
  • 2 in conversation