DATA Step, Macro, Functions and more

Need help to create quarterly dataset report from monthly automated report

Reply
New Contributor Tan
New Contributor
Posts: 3

Need help to create quarterly dataset report from monthly automated report

Hi,

I need to Create quarterly report without changing automated code created for monthly report

Present code as follows:

%let dt1 = '2014-01-01' /* start date for month*/

%let dt2 = '2014-01-30' /* end date for month */

followed by the automated code that creates dataset for this particular month mentioned in dt1 and dt2

when i run the above code it will create report for month Jan 2014. What if i want to create for Jan Feb and march 2014 different datasets and then combine them to create quarterly report.

Could anyone help me with this.

Is there a way i can run for 3 different months either by creating loop or macro and running the automated monthly code without making any changes. and create 3 different dataset and merge results of all three dataset and create quarterly report?

Any help would be appreciated.

Super User
Posts: 5,427

Re: Need help to create quarterly dataset report from monthly automated report

Why separate them into different tables? Just keep them together with the date, and summarize on appropriate level in the report.

Data never sleeps
New Contributor Tan
New Contributor
Posts: 3

Re: Need help to create quarterly dataset report from monthly automated report

The code is created in such a way that final datasets could be created only for a month.

Even for getting 3 months report I cannot change end date to march 2014.

%let dt1 = '2014-01-01' /* start date for month*/

%let dt2 = '2014-03-31' /* end date for month */


And they do not want me to make any changes in this code created by someone else.


So only solution i thought was creating code that will run this code 3 times for 3 different months and then i can combine all datasets into 1 to create quarterly report.


But do not know how to go about.


Any other suggestions appreciated



Super User
Posts: 19,789

Re: Need help to create quarterly dataset report from monthly automated report

1. Remove the macro declarations from the program

2. Change the final output data set to have a unique name per run, perhaps set by another macro variable.

3. Create a master program that sets the macro variable and then includes the old program

4. Call it 3 times

5. Write your code to combine the 3 output datasets together.

Master program would look something like this:

*First month;

%let dt1 = '2014-01-01' /* start date for month*/

%let dt2 = '2014-01-30' /* end date for month */

%let output=January;

%include 'original code.sas';

...


*Third month;

%let dt1 = '2014-03-01' /* start date for month*/

%let dt2 = '2014-03-31' /* end date for month */

%let output=March;

%include 'original code.sas';


*Rest of SAS code to merge/append code as required.


Good Luck!





New Contributor Tan
New Contributor
Posts: 3

Re: Need help to create quarterly dataset report from monthly automated report

Thank you Reeza. Hope that works. I just tried before but there were some issues coming about but will look into it.

Sometimes it just happens you know what to use but do not know how to use them and when to use them.

Thank you so much for giving me a start. Appreciated!

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