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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

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

2 REPLIES 2
Cynthia_sas
Diamond | Level 26

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;

Bill
Quartz | Level 8

Thank you Cynthia!

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
  • 2 replies
  • 1734 views
  • 1 like
  • 2 in conversation