SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anjicam
Calcite | Level 5

Hi Everyone! Below is one of the challenge im facing now.

 

Existing scenario:
There is Excel template file placed in common folder. This template file contains two sheets (sheet1, sheet2). 
Both the sheets contains only Variable Names but no records. Also this Template sheet have Footer information which will be displayed only when we do PRINT PREVIEW of excel.

Current SAS Code using DDE concept and this template file, writes work dataset data to 2nd sheet of template (not in Sheet1)
After exporting SAS data to excel using above DDE concept, this file will be stored to another Folder with another name with datestamp.

Now the output excel file contains 
two sheets ( sheet1 - only variables ,no data ; Sheet2 - both variables and data records) .
Also contains Footer information.

Expected Scenario:
I need to achieve above scenario without USING DDE CONCEPT in SAS ENTERPRISE GUIDE (version: 9.04.01M2P07232014)
I can do this using PROC EXPORT or ODS EXCEL.
but the challange im facing is 
1) In PROC EXPORT, i can export empty dataset data to sheet1 and data to sheet2 BUT i cant include/define FOOTER information.
2) In ODS EXCEL, i can include/define FOOTER information BUT i can't export empty dataset data to sheet1.

HOW TO ACHIEVE THIS. PLEASE HELP ME 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:
But you said that sheet one is not really empty -- it has the variable names, correct? Are the variable names in row 1? Then sheet 2 has the "real" data. Since you are using SAS 9.4 M2, I would recommend using ODS EXCEL. You'll have to write code to do what you want to do.
Cynthia

 

This is what I envision you are describing:

two_sheet_output.png

 

The above output was generated with this code:

two_sheet_code.png

View solution in original post

6 REPLIES 6
Reeza
Super User

What version of SAS are you using? Option 2 should work with the latest version, but that may be 9.4 M6. 

 

But you can also export your data to a template file that already has the footnote/titles you need or use VB to add it after the fact. T

anjicam
Calcite | Level 5

Hi, i m using SAS ENTERPRISE GUIDE (version: 9.04.01M2P07232014)

Cynthia_sas
SAS Super FREQ

Hi:
But you said that sheet one is not really empty -- it has the variable names, correct? Are the variable names in row 1? Then sheet 2 has the "real" data. Since you are using SAS 9.4 M2, I would recommend using ODS EXCEL. You'll have to write code to do what you want to do.
Cynthia

 

This is what I envision you are describing:

two_sheet_output.png

 

The above output was generated with this code:

two_sheet_code.png

anjicam
Calcite | Level 5
Thank you Cynthia. thank you somuch.
anjicam
Calcite | Level 5
Thanks for the answer. Could you please also tell how to have gridlines instead of whited out all the remaining rows n columns
Cynthia_sas
SAS Super FREQ
Hi:
I think there's a suboption to turn gridlines on INSIDE the table, if that's what you're referring to.

However, if you are referring to the fact that the gridlines outside of the table do not show, I believe that is Excel using the background from the style overlaid on top of the gridlines. If you want to make the background go away, I believe you need to change the style template.

Or, if you truly only want the data without ANY style (colors or fonts) at all, then move to PROC EXPORT or LIBNAME XLSX methods of getting your data from SAS into Excel.
Cynthia

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 5005 views
  • 0 likes
  • 3 in conversation