12-01-2016 11:37 AM
I am trying to do a VERY simply macro, and I can't figure out what is wrong!
%let medrec=FA_MEDREC; data &medrec; infile 'C:\Users\t46837uhn\Documents\Med Rec\Med Rec Evaluation\round3\&medrec.csv' informat MRN best32.; format MRN best13.; input MRN; run;
I keep getting the error in the log:
ERROR: Physical file does not exist, C:\Users\t46837uhn\Documents\Med Rec\Med Rec Evaluation\round3\&medrec.csv. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.FA_MEDREC may be incomplete. When this step was stopped there were 0 observations and 255 variables. WARNING: Data set WORK.FA_MEDREC was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.35 seconds cpu time 0.32 seconds
But the file MOST DEFINITELY exists. I've triple checked that it is the correct name as well and in the right file path.
what the heck am I doing wrong?
I also tried doing:
%macro test (medrec=FA); data &medrec; infile 'C:\Users\t46837uhn\Documents\Med Rec\Med Rec Evaluation\round3\&medrec.csv' informat MRN best32.; format MRN best13.; input MRN; run; %mend test;
But this also doesn't work.
12-01-2016 11:45 AM
It looks like the macro variable medrec is not resolving correctly on your infile statement due to the use of single quotation marks, so if you tried using double quoation marks this will resolve the macro variable?
12-01-2016 12:03 PM
Macro triggers (& or %) are not resolved in strings delimited by single quotes. Always use double quotes when macros or macro variables need to be resolved.
12-01-2016 02:05 PM
You may need:
infile "C:\Users\t46837uhn\Documents\Med Rec\Med Rec Evaluation\round3\&medrec..csv"
Note the SECOND .
The first . will be treated as the end of a macro variable name.
See the difference between:
The first will not resolve to the external file name even after the quotes.
Also their is a very good reasons for the differences between " " and ' ' because you may have other code that is not intended to be a macro reference and you do not want the macro processor telling you that code bits that were not intended as macros references are an error.
Need further help from the community? Please ask a new question.