BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
seboi49
Fluorite | Level 6

Hi, 

 

I'm trying to create a sum of two variables with PROC REPORT. I'm new with this procedure and I'm not sure if it is possible to do what I'm looking for. Here is my code : 

 

PROC REPORT data=Res_perfo_overall nowd;
column Ref_Meth_POS nPositivePOS nNegativePOS;
define nPositivePOS / display;
define nNegativePOS / display;
define Ref_Meth_POS / computed "RM POS";
compute Ref_Meth_POS;
	Ref_Meth_POS = nPositivePOS + nNegativePOS;
endcomp;
run;

 I'm getting this output : 

RM POS nPositivePOS nNegativePOS
.18113
.00
.485
.00
.72

 

I just want to know if it is possible to display the sum of the two colums with proc report instead of creating the variable in a data step (like 181+13, 0+0, 48+5, 0+0 and 7+2). If not I will create it directly in my data but I'm curious if it's possible?

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You might try:

PROC REPORT data=Res_perfo_overall nowd;
column  nPositivePOS nNegativePOS Ref_Meth_POS;
define nPositivePOS / display;
define nNegativePOS / display;
define Ref_Meth_POS / computed "RM POS";
compute Ref_Meth_POS;
	Ref_Meth_POS = _c1_ + _c2_;
endcomp;
run;

Proc Report builds tables from left to right. So if you need a calculation then the result must be to the right of all the variables used.

Second to use the values of cells you use the column number to reference, not the variable name.

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

You might try:

PROC REPORT data=Res_perfo_overall nowd;
column  nPositivePOS nNegativePOS Ref_Meth_POS;
define nPositivePOS / display;
define nNegativePOS / display;
define Ref_Meth_POS / computed "RM POS";
compute Ref_Meth_POS;
	Ref_Meth_POS = _c1_ + _c2_;
endcomp;
run;

Proc Report builds tables from left to right. So if you need a calculation then the result must be to the right of all the variables used.

Second to use the values of cells you use the column number to reference, not the variable name.

 

 

seboi49
Fluorite | Level 6
All right thank you for your help!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 1786 views
  • 1 like
  • 2 in conversation