BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

I can not get what exactly "(" should be placed in the codes

How to solve this?

data trans_summary(drop=txn_amt_rmb);
	set trans_list;
		by party_id plus_minus_flag;
		retain sum_rmb;
		if first.plus_minus_flag then sum_rmb=0;
		sum_rmb=(sum_rmb,txn_amt_rmb);
		if last.plus_minus_flag then output;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You reversed things on the OUTPUT statement.  The original incorrect version:

output out=trans_summary sum_rmb=sum(txn_amt_rmb);

 

Within an OUTPUT statement, you need to reverse the request:

 

output out=trans_summary sum(txn_amt_rmb)=sum_rmb;

Or, since there is only one variable in the VAR statement, simply:

output out=trans_summary sum=sum_rmb;

 

View solution in original post

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This line:

sum_rmb=(sum_rmb,txn_amt_rmb);

Does not make sense.  A variable cannot hold two parameters.  Think your missing sum:

sum_rmb=sum(sum_rmb,txn_amt_rmb);

 

Geo-
Quartz | Level 8

thank you~another little question..how to fix it

ERROR 73-322: expecting =

proc summary data=trans_list;
	class party_id plus_minus_flag;
	var txn_amt_rmb;
	output out=trans_summary sum_rmb=sum(txn_amt_rmb);
run;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

That is nothing like your first post.  Please post examples of the actual question and code in future.

proc summary data=trans_list;
	class party_id plus_minus_flag;
	var txn_amt_rmb;
	output out=trans_summary sum=sum_rmb;
run;
PaigeMiller
Diamond | Level 26

In the OUTPUT statement, you can't use a SUM function as you are trying to do, the SUM= option will create the sums of whatever variable(S) you have in the VAR statement, and then assign that sum to the variable name after the = sign.

 

output out=trans_summary sum=sum_txn_amt_rmb;
--
Paige Miller
Astounding
PROC Star

You reversed things on the OUTPUT statement.  The original incorrect version:

output out=trans_summary sum_rmb=sum(txn_amt_rmb);

 

Within an OUTPUT statement, you need to reverse the request:

 

output out=trans_summary sum(txn_amt_rmb)=sum_rmb;

Or, since there is only one variable in the VAR statement, simply:

output out=trans_summary sum=sum_rmb;

 

Kurt_Bremser
Super User

@Geo- wrote:

thank you~another little question..how to fix it

ERROR 73-322: expecting =

proc summary data=trans_list;
	class party_id plus_minus_flag;
	var txn_amt_rmb;
	output out=trans_summary sum_rmb=sum(txn_amt_rmb);
run;

Follow Maxim 1 and read the documentation for the summary procedure. Your mistake will become obvious.

Peter_C
Rhodochrosite | Level 12
A parenthesised list following SUM= on the OUTPUT statement of PROC MEANS, should have one name per var name on the VAR statement

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 11426 views
  • 7 likes
  • 6 in conversation