BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Selli5
Fluorite | Level 6

Hello,

 

I am getting the following error message:

WARNING: Apparent symbolic reference I_28MAY17 not resolved.
WARNING: Apparent symbolic reference I_28MAY17 not resolved.
 
ERROR: Physical file does not exist, /folders/myfolders/sasuser.v94/tran.&i_28MAY17..csv.
 
When I run the following code.  

 

%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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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
  ;

 

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-tex...

Tom
Super User Tom
Super User

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
  ;

 

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 1318 views
  • 1 like
  • 3 in conversation