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

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

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!

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