The SAS Output Delivery System and reporting techniques

ODS TAGSETS.EXCELXP No header

Reply
Occasional Contributor
Posts: 13

ODS TAGSETS.EXCELXP No header

Hi,

So I need to send a create a ODS TAGSETS.EXCELXP with no headers, as it has to line up with an excel spreadsheet that has been manually created. Any thoughts on this? The closest I've gotten has been:

 

DATA TEMP.EXAMPLE_OUT (DROP=RECORD) ;  (Previous information brought in)
ARRAY COL $80 COL1-COL80;
INFILE "&EXAMPLE.OUT" TRUNCOVER ; (Previously called in macro variable)
INPUT @ 01 Record $CHAR500.;
COL[1] = SUBSTR(Record,1,80);
IF INDEX(Record,"|") GE 1
THEN DO;
DO LOOP = 1 TO 80;
COL[LOOP] = SCAN(Record,LOOP,"|");
END;
END;
RUN;
PROC EXPORT DATA= EXAMPLE_OUT
OUTFILE= "C:\SPREAD.xlsb.xls"
DBMS=xls REPLACE;
PUTNAMES=NO;
SHEET="INFO";
RUN;

 

This pulls the information into the spreadsheet that has been previously created, but with lots of issues, i.e Marcos not working, permissions, ect. This is unfortunately an excel multisheet that pulls information from bloomberg (financial) and was created years ago and i don't have the time or understanding of the financial side to make a new version of the spreadsheet and would like my output to load into the preexisting one with no error, or boxes to click, as it will need to be fully automated. Any help is appreciated

Super User
Posts: 19,805

Re: ODS TAGSETS.EXCELXP No header

Posted in reply to XMonsterX
I'm not 100% sure I understand you, but I'll try an answer.
You can't use Tagsets to load into a pre-existing excel file. If your output is a fixed size, I recommend creating the template with Named Ranges and then you can use SAS to export the data to the Named Ranges. Unfortunately I don't think there's a way to drop the headers, but you can export to a named ranges that is then linked to the appropriate area of the worksheet.

Or you can use DDE to explicitly export to where you want - this is considered old, unsupported and avoid at all costs, but I use it regularly as its faster than copy and paste.

A third option, which may be your best option is using a macro to export which was developed by some SAS users. I think the code underneath is VBS. Read the paper/presentation and check out the examples.

http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export
SAS Super FREQ
Posts: 8,866

Re: ODS TAGSETS.EXCELXP No header

Hi:
Proc REPORT has a NOHEADER option for reports. But your main question was answered by Reeza -- you can't use ODS to add information to an existing sheet in a workbook. Every time ODS runs, it recreates the file that you specify in the FILE= option.

cynthia
Super User
Super User
Posts: 7,955

Re: ODS TAGSETS.EXCELXP No header

Posted in reply to XMonsterX

Hi,

 

First and foremost, please dont code all in upper case, without prpoer indentation, it makes reading the code so much harder.

Secondly, at no point here are you creating a excelxp style tagset output file?

Thirdly, the filename given in the code - spread.xlsb.xls - doesn't seem to make much sense, are you creating:

- an XLS file which is a binary file standard strcuture pre-open office

- an XLSB file which is an open office binary component (i.e macro enabled) document

- an XLSX which is an open office standard Excel file

- or an ods tagset generated XML document which Excel can read

 

Finally, if your stuck with an Excel file which you need to add data into (and if so your going to end up fighting it for the rest of its existence) then why not switch the thinking around.  I.e. You have some data in SAS, you need to load it into Excel.  So, export the data from SAS as CSV - simple step.  Now in the Excel (or another one, it only needs to hold some code) wriet a small VBA macro which allows you to select a file, opens that file into a new sheet, copies the data over as you want, then deletes the new sheet.  Simple, this keeps the Excel file the same as it was, just uses Excel VBA to update.  And if your stuck using Excel, why not use its full potential.  Lots of examples of how to do this:

http://www.zerrtech.com/content/excel-vba-open-csv-file-and-import

https://msdn.microsoft.com/en-us/library/office/ff840655.aspx

 

I would not suggest using DDE, its old and may not be supported, plus only has the functionality of the version all the way back then.

 

Ask a Question
Discussion stats
  • 3 replies
  • 431 views
  • 0 likes
  • 4 in conversation