BookmarkSubscribeRSS Feed
XMonsterX
Obsidian | Level 7

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

3 REPLIES 3
Reeza
Super User
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
Cynthia_sas
SAS Super FREQ
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
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 1243 views
  • 0 likes
  • 4 in conversation