BookmarkSubscribeRSS Feed
jaecheverrys
Calcite | Level 5

Hello everyone,

 

I am Julian and I need to produce a table that shows the layout you can see in this picture.

 

foto tabla.JPG

 

Using the following PROC TABULATE program in SAS Enterprise Guide 7.1 – 32 bits I’ve been able to produce all the  columns except for the “Cumulative % of the Sum_Var2” one.

 

PROC TABULATE DATA= Julian.Mydata NOSEPS ;
         TITLE1 'Table 3';
   WEIGHT weight_var;
   CLASS  category_var / PRELOADFMT EXCLUSIVE;
   VAR Var1 Var2;
         TABLE (ALL='TOTAL' category_var=' '),
               (SUM='Sum_Var1'*Var1=' '*ALL=' '*F=COMMAX16.0
     SUM='Sum_Var2'*Var2=' '*F=dollar16.0
     MEAN='Mean_Var2'*Var2=' '*F=dollar16.0
     COLPCTSUM='% of the Sum_Var2'*Var2=' ')
      /RTS=25 PRINTMISS BOX='Categories' CONDENSE;
FORMAT category_var category_var.;
FOOTNOTE 'Source';
RUN;

Do you know a method to create that column without losing the visual features of the PROC TABULATE?

 

Thanks. I will be looking forward to your help.

2 REPLIES 2
ballardw
Super User

If you are attempting what I think you want then you can't do that in Tabulate as a single step. The percent calculations have to use either the n or sum of a table, row or column and cannot do sum or row1 and row2.

 

So you may have to presummarize everything. Without specific data and actual expectation I can't get more specific for suggestions on how.

mkeintz
Jade | Level 19

You could use ODS OUTPUT to write the tabulate table to a dataset.  Then create the cum_pct var from the PCT var, followed by a proc print.  Here's a schematic:

 

 


ods output tabulate.report.table=MYTABLE; proc tabulate data=mydata ; class ...; var ...; table .... ; run; ods output close; /* Assume the pct var name is var2_pctsum_0_var2 */ data want; set mytable; cumpct+var2-pctsum_0_var2; run; proc print data=want; .... run;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2961 views
  • 0 likes
  • 3 in conversation