BookmarkSubscribeRSS Feed
AshokD
Obsidian | Level 7

Hi All,

 

I need a help on creating a SAS report in xls file. On a daily basis , we are generating a report with multiple sheets in a single xls file. 

We need to amend a new sheet with the below data set content which is getting populated daily with different values:-

 

Obstextvolume_final
1Cycle Due = 2 2
2Cycle Due = 32
3Cycle Due = 4 0
4Cycle Due = 52

 

* Content of the report should look like as below:-

#1) For example , I am running the job on January month - Day 1 , the above data set values needs to be posted as below and when comes to Day 2 , above data set will populate different values and needs to be append to the below sheet and it continues till day 31 of January.  Also , we need to calculate  the sum up the totals at the end of the report.

* #2)  Above Step #1 , will be followed for all the months in 2019 Jan -Dec , for the upcoming months new column needs to be added when we run the code at the respective months and also for the upcoming years as well.

 

 2019
 JANUARYFEBRUARY
 Cycle Due = 2 Cycle Due = 3Cycle Due = 4Cycle Due = 5Cycle Due = 2 Cycle Due = 3Cycle Due = 4Cycle Due = 5
D122022000
D210013011
D331001100
D410001001
D510002000
D630002001
D720000000
D820024000
D910120000
D1010003000
 1731718113

 

Can someone share your thoughts to achieve this report either SAS or VBA script would be fine for this ?

Also , need a suggestion on the base coding part since I don't have a idea on where to start ?

 

Thanks in advance for your help.

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

My opinion - as there is always several ways to do any tasks - is to, in order of preference:

1) Use either an application designed for the task.  In this case a web front end reporting suite rather than Excel.  You can design a report which pulls in data from sources and creates nice reports which can be exported if needs be.  This method is most robust, controllable, and flexible but can cost in money and resource to get going.

 

2) Use the software you "have" to use.  In this case you have to use Excel (presumably), so dump out the SAS data to a CSV, and then add a VBA macro (doesn't even need to be in the destination file as that could be a plain Excel file which opens source and destination), which updates the source destination with the CSV data.  In this method you need to know VBA coding, and a tiny bit of SAS, and can use full functionality of Excel.

 

3) Rebuild the report either by reading in the source destination into SAS and then updating, writing out, or by somehow appending new data (depends on SAS version, knowledge of SAS).  This would be my least favorite and you can't use all the functionality of Excel.

 

As such its hard to give any real answer to this question.  I mean your data can be transposed easily enough with a proc transpose:

https://support.sas.com/resources/papers/proceedings09/060-2009.pdf

And you can achieve your output (assuming you are on version 9.3) by using ods excel and proc report, and have a split char in column one as:

define col2 / "2019*JANUARY*Cycle Due = 2";

However if you know no SAS then you will struggle.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 532 views
  • 0 likes
  • 2 in conversation