DATA Step, Macro, Functions and more

ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

Does anyone know how to output 'equal to' sign to excel file using ODS tagsets.

 

compute equalsign2 / character length=2;
     equalsign2 = "=";
endcomp;

 

This does not work because it considers it to be a formula


Accepted Solutions
Solution
‎03-06-2016 01:40 PM
Super User
Posts: 9,687

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

How about this :

 

ods tagsets.excelxp file='c:\temp\xyz.xml';
proc report data=sashelp.class nowd;
column name age equalsign ;
define name/display;
define age/display;
define equalsign /computed;
compute equalsign / character length=4 ;
   equalsign = '09'x||'=';
endcomp;
run;
ods tagsets.excelxp close;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,115

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

Have you tried this?

equalsign2 = "'=";

(I'm only guessing. I don't have Excel installed on my SAS workstation.)

 

Occasional Contributor
Posts: 13

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

yes i have. but then when i open the excel file it appears as '=

 

the sign quote disapears only when you go to that cell and move out of it

Trusted Advisor
Posts: 1,115

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

What will be the purpose of the equals sign in the Excel cell, if not the beginning of a formula?

 

My Excel 2013 accepts a (manually entered) single equals sign without any problem. Therefore, I assume that in your case there will be some text to the right of the equals sign (a combination which would indeed be interpreted as a formula). Is this true?

 

An expression like " =abc" (without quotation marks, but with a leading blank) does not seem to be interpreted as a formula. Would this be an option?

Occasional Contributor
Posts: 13

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

The purpose of puting the equal to sign is to display 2 + 2 = 4

 

I need to display this statement as it is.

 

2

+

2

=

4

 

they all are in different cells and there is no text after the equal as you see in the example given

Trusted Advisor
Posts: 1,115

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

Thanks for the clarification. What exactly is the issue (e.g. error message) when you put the single equals sign into a cell?

 

If the " =" (equals sign preceded by a space) is not acceptable for you, we could try a variety of other ASCII characters (from the code range 0, ..., 31) as replacements for the space (ASCII 32). I've just written all of these together with an equals sign into individual cells of an Excel sheet and several of them seem to be totally invisible (i.e. do not even appear as a blank space to the left of the equals sign, neither in Excel, nor in Notepad). ASCII 31 (hex 1F) is one of these. So, maybe this would be a candidate:

equalsign2 = '1F3D'x;

('3D'x is the equals sign in hexadecimal notation.)

Occasional Contributor
Posts: 13

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

Thank you for your support.

 

Below is the message output to a log file. I'm using SAS University Edition.

Actually it is considering the equal sign as the beginning of a formula.

 

compute equalsign / character length=4 ;
                                 equalsign = '3D'x;
endcomp;

 

XML Spreadsheet Warning in Table
REASON: Bad Value
FILE: C:\Myfile.xls
GROUP: Row
TAG: Cell
ATTRIB: Formula
VALUE: =

 

 

 

Trusted Advisor
Posts: 1,115

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

Ok, I see. Have you tried '1F3D'x (or '1E3D'x or '1D3D'x or ...)?

Occasional Contributor
Posts: 13

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

YES JUST TRIED THANKS.

 

USING THESE 3, IT DISPLAYED

 

?=

Occasional Contributor
Posts: 13

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

going to bed now, will catch ya tomorrow

thanks a million.

Solution
‎03-06-2016 01:40 PM
Super User
Posts: 9,687

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

How about this :

 

ods tagsets.excelxp file='c:\temp\xyz.xml';
proc report data=sashelp.class nowd;
column name age equalsign ;
define name/display;
define age/display;
define equalsign /computed;
compute equalsign / character length=4 ;
   equalsign = '09'x||'=';
endcomp;
run;
ods tagsets.excelxp close;
Occasional Contributor
Posts: 13

Re: ODS OUTPUT 'EQUAL TO' CHARACTER TO EXCEL

That worked beautifully

 

Thanks a lot.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 390 views
  • 1 like
  • 3 in conversation