Hello all:
This is just an easy example (because my actual scenario is a little more complicated). My eventual goal is to output to excel via the ods tagsets.excelxp option and I want to create a column that is a formula (for example, =A1+B1). But let's say I have the following data:
now, let's say I want to create a column (C) that is the sum of A+B:
So the data looks as follows:
A B obs C
1 1 2 =A2+B2
2 2 3 =A3+B3
3 3 4 =A4+B4
4 4 5 =A5+B5
So, after I send it to excel (using PROC REPORT and the ods tagsets), I get the following formulas in column C:
='A2'+'B2'
='A3'+'B3'
='A4'+'B4'
='A5'+'B5'
Unfortunately, for whatever reason, when the PROC REPORT gets sent to excel, it is putting ' ' (quotes) around the cell numbers which excel doesn't understand (the actual cell output is #NAME?) and so it does not compute anything for any of those rows. If I remove the ' ', then everything is fine and the column C looks as follows:
2
4
6
8
which is what I want. Does anybody have any clue why the ' ' are getting placed within the formulas (they are not there in SAS, just when it gets sent to excel) and how to remove them?
This is just an easy example (because my actual scenario is a little more complicated). My eventual goal is to output to excel via the ods tagsets.excelxp option and I want to create a column that is a formula (for example, =A1+B1). But let's say I have the following data:
Code:
data test;
input A B;
cards;
1 1
2 2
3 3
4 4
;
run;
Code:
data test;
set test;
obs=_N_+1;
C=compress('=A'||obs||'+B'||obs);
run;
So the data looks as follows:
A B obs C
1 1 2 =A2+B2
2 2 3 =A3+B3
3 3 4 =A4+B4
4 4 5 =A5+B5
So, after I send it to excel (using PROC REPORT and the ods tagsets), I get the following formulas in column C:
='A2'+'B2'
='A3'+'B3'
='A4'+'B4'
='A5'+'B5'
Unfortunately, for whatever reason, when the PROC REPORT gets sent to excel, it is putting ' ' (quotes) around the cell numbers which excel doesn't understand (the actual cell output is #NAME?) and so it does not compute anything for any of those rows. If I remove the ' ', then everything is fine and the column C looks as follows:
2
4
6
8
which is what I want. Does anybody have any clue why the ' ' are getting placed within the formulas (they are not there in SAS, just when it gets sent to excel) and how to remove them?