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 :
. | 181 | 13 |
. | 0 | 0 |
. | 48 | 5 |
. | 0 | 0 |
. | 7 | 2 |
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!
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.
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.