Hi everyone, I'm pretty new to macros in SAS and I'm stuck with a problem that seems like it should be pretty straightforward. I'm trying to read a set of excel sheets into SAS that all have a similar prefix in the filename but different suffixes, eg Temp 9-28-12, Temp 9-29-12, Temp 9-30-12. I wrote a simple macro that reads in an individual sheet: %MACRO read_dates (date, outfile); proc import datafile="C:\Users\Ben\Documents\Time Series 2\Data\All Phoenix Temps\Phoenix Temp &date..csv" DBMS=CSV Out=Phoenix.&outfile REPLACE; run; %mend read_dates; A sample call to this function would be: %read_dates(9-23-13,test1); I've tested this and it works. However, I'm having difficulties when I try to read multiple sheets consecutively. I tried creating a macro with an array consisting of different dates, which I could use a do loop to iterate through. However, I kept getting errors so I created a 'setup' macro that calls the read_dates macro, which is in turn called from a data step. For now I'm leaving aside the problem of creating differently named sas datasets, that's why I'm just renaming each set 'test1'. The code follows: %macro setup(dt); %read_dates(dt,test1) %mend setup; data dates1; array dates {17} $ d1-d17 ('9-23-13','9-24-13','9-25-13','9-26-13','9-27-13','9-28-13', '9-29-13','9-30-13','10-1-13', '10-2-13','10-3-13', '10-4-13', '10-5-13', '10-6-13', '10-7-13','10-8-13','10-9-13'); do i=1 to 17; %setup(dates{i}) end; run; When I run this I get the error message: There was 1 Unenclosed DO Block. I'm not sure where this is coming from. I've tried making a number of modifications without any luck. Can someone point out where I am going wrong? Thanks!
... View more