The SAS Output Delivery System and reporting techniques

Using Computed Columns in Proc Report

Reply
N/A
Posts: 0

Using Computed Columns in Proc Report

Hi! I have a report which is grouped according to a string variable and requires a computation of two columns, specifically division. And I always encounter an error saying that there's a division of missing values. But there are no missing or even zero values in my data. I saw compute examples using a constant (e.g sales.sum) in SAS help. Is it possible that I divide two columns using proc report? Thanks in advance!

If it may help, here's a proxy of my code:

proc report data = trial;
column color intensity intensity,(pct_int pctn) specks pct_specks_intense;
define color/ group;
define intensity/analysis sum;
define pct_int/ percent6.;
define specks/ analysis sum;
define pct_specks_intense;
compute pct_specks_intense;
pct_specks_intense = (_c2_)/(_c4_);
endcomp;
run;
SAS Super FREQ
Posts: 8,868

Re: Using Computed Columns in Proc Report

Posted in reply to deleted_user
Hi:
If your variable PCT_SPECKS_INTENSE is a computed report item (that means it does NOT already exist in WORK.TRIAL, then I would expect you to have a syntax error in your log that says something like:
[pre]
ERROR 22-322: Syntax error, expecting one of the following: -, /, :.
[/pre]

In the examples you have seen SALES.SUM is NOT a constant, not in the sense that it would always be 500. SALES.SUM would come from a DEFINE statement such as this:
[pre]
define sales / analysis sum 'Sales' f=dollar12.;
[/pre]

and in one possible program, I might see:
[pre]
column region sales bonus;
define region / group 'Region';
define sales / analysis sum 'Sales' f=dollar12.;
define bonus / computed 'Bonus';
compute bonus;
bonus=sales.sum * 1.50;
endcomp;
[/pre]

In the above code snippet, SALES.SUM for the ASIA region would be a different number than SALES.SUM for the CANADA region....so SALES.SUM is a "compound name" that references the SUM of the SALES report item for every GROUP (in this case, for every REGION).

It is possible to do division within PROC REPORT. I suspect you have other issues in your code. You might want to contact SAS Tech Support for more help, or provide some dummy data and the EXACT code that you're using here, as well as an example of the desired output that you want to see.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 119 views
  • 0 likes
  • 2 in conversation