1
votes

I need to rerun the same program with data from different months and create a separate excel spreadsheet for each month. What is a shorter way to program this in SAS than to run each program separately? For example in the following I read data from October, and at the end of the same program I output the October results to excel. I need to do the same for each month. Can I do it in one SAS program (maybe using Macro)? Thanks.

data sourceh.trades2;
set sourceh.trades1_october08_wk1;
if time<34200000 or time>57602000 then delete;
run;

proc export data=sourceh.avesymbol        
outfile='C:\Documents and Settings\zd\My Documents\h\hdata\trades\2008\October 08 1 min       correlations.xls'           
replace; 
run;
1

1 Answers

2
votes

I would use a macro for that. Here I have wrapped your code into a macro which you can execute with the RunProgram(); macro statement for each desired month and year.

%MACRO RunProgram(month, year);
data sourceh.trades2;
set sourceh.trades1_&month.&year._wk1;
if time<34200000 or time>57602000 then delete;
run;

proc export data=sourceh.avesymbol        
outfile="C:\Documents and Settings\zd\My Documents\h\hdata\trades\2008\&month. &year. 1 min correlations.xls"         
replace; 
run;
%MEND RunProgram;


%RunProgram(October, 08);
%RunProgram(November, 08);