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
;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.