Hello,
I am getting the following error message:
%macro onetime;
%local i;
%do i=1 %to 37 %by 1;
DATA temp_&i;
INFILE "/folders/myfolders/sasuser.v94/tran.&i_28MAY17..csv" DSD delimiter=',' missover firstobs=2;
informat Date Date. Credit 8.2 Debit 8.2;
FORMAT Date :DATE. Credit dollar.0 Debit dollar.0;
INPUT
Account :$8.
Tran_Code :$4.
Date
Credit
Debit
Desc :$100.
;
RUN;
%end;
%mend onetime;
%onetime;
How do I fix the code?
thanks
Your program is asking for that macro variable, but you haven't defined it. I suspect that you really want to reference the macro varaible I but the way you wrote the filename you did not tell SAS that. When the macro variable name is followed immediately by characters like underscore, digits and letters that could be part of a valid macro variable name you need to add a period so that the macro processor knows where the name of the macro variable ends.
Also does your filename really have two periods before the csv extension?
%do i=1 %to 37 %by 1;
DATA temp_&i;
INFILE "/folders/myfolders/sasuser.v94/tran.&i._28MAY17.csv"
DSD delimiter=',' missover firstobs=2
;
This line:
INFILE "/folders/myfolders/sasuser.v94/tran.&i_28MAY17..csv" DSD delimiter=',' missover firstobs=2;
^
At the carat here you have put the point which means the macro variable is &i_28MAY17. This isn't what you wanted, maybe:
INFILE "/folders/myfolders/sasuser.v94/tran.&i._28MAY17.csv" DSD delimiter=',' missover firstobs=2;
Per your other post however, if you read Reeza's advice you will see that you do not need macro at all, there are far simpler methodologies, I cut and paste the link for your reference:
Your program is asking for that macro variable, but you haven't defined it. I suspect that you really want to reference the macro varaible I but the way you wrote the filename you did not tell SAS that. When the macro variable name is followed immediately by characters like underscore, digits and letters that could be part of a valid macro variable name you need to add a period so that the macro processor knows where the name of the macro variable ends.
Also does your filename really have two periods before the csv extension?
%do i=1 %to 37 %by 1;
DATA temp_&i;
INFILE "/folders/myfolders/sasuser.v94/tran.&i._28MAY17.csv"
DSD delimiter=',' missover firstobs=2
;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.