BookmarkSubscribeRSS Feed
Nooby1Konoby
Calcite | Level 5
I am very new to SAS and I'm having a problem with PROC REPORT. I have looked through "The Little SAS Book" and some online doc, but can't find an answer. I have some raw data that I'm trying to calculate. can anyone tell me how to subtract one variable from another to produce a variable that is not in the input data or is that not possible with PROC REPORT? This is a sample of my input and also of my SAS code, if that helps. I am trying to sum VOLCAPGB then subtract the variable VOLCAPGB from the grouped variable CONTRACT to produce REMAINING. I basically want the end result to look like this(below in bold), of course this example is just a portion of my data, its rather large. Any help would be greatly appreciated.

CONTRACT VOLCAPGB REMAINING
163000 160 162840


(Input Data)

CONTRACT VOLCAPGB

163000 27
163000 27
163000 27
163000 27
163000 27
163000 27


PROC REPORT DATA=MAP HEADLINE NOWD;

COLUMN CONTRACT VOLCAPGB REMAINING;

DEFINE CONTRACT / GROUP;
DEFINE VOLCAPGB / ANALYSIS SUM;
DEFINE REMAINING / ?????????????????????
5 REPLIES 5
Tim_SAS
Barite | Level 11
Sounds like REMAINING is a "computed" variable. See this doc: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473627.htm#a003072061.
Nooby1Konoby
Calcite | Level 5
I tried to compute the REMAINING variable and my job fails with the below message; which appears that I'm not able to compute the variable with another one that is being analized. I'll keep digging to see what I can come up with. Thanks again for the help.


ERROR: There is more than one ANALYSIS usage associated with
the column defined by the following elements.

Name Usage
-------------------------------- --------
VOLCAPGB ANALYSIS
REMAINING COMPUTED
Nooby1Konoby
Calcite | Level 5
Tim

Sorry I found that I had a syntax error. I was able to get the compute to work, kind of. It is giving me a value of zero, but i think that should be easy to fix. Thanks you very much for the information and the help.
Tim_SAS
Barite | Level 11
Since VOLCAPGB is an analysis variable you'll have to refer to its value by its statistic, VOLCAPGB.SUM. See "Using Compute Blocks" on this page: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000146851.htm.
Nooby1Konoby
Calcite | Level 5
Tim

Thank you very much! This worked like a charm. I'll have to spend some more time reading over the links that you provided me. I'm glad I joined this forum, thanks again!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2990 views
  • 0 likes
  • 2 in conversation