BookmarkSubscribeRSS Feed
Tan
Calcite | Level 5 Tan
Calcite | Level 5

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.

4 REPLIES 4
LinusH
Tourmaline | Level 20

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

Data never sleeps
Tan
Calcite | Level 5 Tan
Calcite | Level 5

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



Reeza
Super User

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!





Tan
Calcite | Level 5 Tan
Calcite | Level 5

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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