BookmarkSubscribeRSS Feed
deleted_user
Not applicable
How do i calculate new columns based on columns in a summary table. I.e I create a summary table which gives me exactly what i want and how i want to see the data. However i want to make a calculation based on two of the columns in the sumary table.

If i output the summary table as a data table the format of the data completly changes. The data table changes the summary table columns into rows.
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
The question is: what is your procedure of choice? What are you currently using to create the summary table?

If you are using PROC FREQ or PROC TABULATE or PROC MEANS to create your summary table, then the answer is NO, you cannot make a calculation based on summary columns unless you create an output dataset and then use that dataset within a program that does the calculation.

However, PROC REPORT, using a COMPUTE block, can create calculated columns using existing report columns. As shown in the program below. For more information on PROC REPORT, you might consult these sites:
http://support.sas.com/documentation/onlinedoc/v82/techreport_p258.pdf
http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf
http://support.sas.com/documentation/cdl/en/proc/59565/HTML/default/report-overview.htm

PROC REPORT can create cross-tabular reports too. The computations with ACROSS variables are do-able, but you need to use the "absolute" column names for the ACROSS vars, instead of the dataset name. That's because each report column that comes from an ACROSS usage gets a unique number of its own. The second document above shows an example of doing this.
cynthia
[pre]
ods html file='c:\temp\compute_examp.html' style=sasweb;
proc report data=sashelp.prdsale nowd;
column division prodtype n actual predict diff;
define division / group;
define prodtype / group;
define actual / sum;
define predict / sum;
define n / 'Count of Sales';
define diff / computed f=dollar8.;
rbreak after / summarize;
compute diff;
diff = actual.sum - predict.sum;
endcomp;
run;
ods html close;
[/pre]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 901 views
  • 0 likes
  • 2 in conversation