BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 569 views
  • 0 likes
  • 2 in conversation