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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 2050 views
  • 0 likes
  • 2 in conversation