I have a macro in which some parts are like following:
OPTIONS OBS=MAX FIRSTOBS=1;
DATA Search_Hits (KEEP=Search_Arg Full_Path Path Program_Nam Col Line_cnt Search_Tab Search_Col
Search_Rec );
LENGTH Search_Arg $40
Search_Tab $40
Search_Col $40
Search_Rec $&Search_reclen
Suf $2
;
RETAIN Line_cnt 0
;
EOFx = 0;
SET search_obj_names;
fv = srch_file;
pn = program_nam;
Line_Cnt = 0;
INFILE dummyf FILEVAR=fv
FILENAME=pn
END=EOFx
MISSOVER
TRUNCOVER
;
in the above code i have the value of fv and pn , basically they are some file names.And later the code is following:
IF EOFx THEN;
ELSE
DO UNTIL (EOFx
);
INPUT @ 1 Search_rec $&search_reclen..
;
Line_cnt + 1;
Search_rec_UC = UPCASE(Search_rec);
%DO J = 1 %TO &maxfind;
*** identify possible match in code *** ;
Col = INDEX(Search_rec_UC, &&find&J );
*** validate the match is not embedded in another string ***;
IF scan( substr( Search_rec_UC , Col ) , 1 ) EQ &&find&J THEN
match_flg=1;
ELSE
match_flg=0;
IF match_flg=1 THEN
DO;
Search_Arg = &&find&J;
Full_Path = srch_file;
IF &&typ&J = 'T' THEN
DO;
Search_Col = '';
Search_Tab = Search_Arg;
END;
ELSE
DO;
Search_Tab = '';
Search_Col = Search_Arg;
END;
OUTPUT Search_Hits;
END;
%END;
END;
RETURN;
RUN;
but i m facing the following error:
ERROR: Physical file does not exist, C:\Documents and Settings\237820\SAS.
I think we have issues regarding the following part:
INFILE dummyf FILEVAR=fv
FILENAME=pn
END=EOFx
MISSOVER
TRUNCOVER
Whenever the above part ran it searches filename present in the fv/pn in C:\Documents and Settings\237820\SAS. But these files are present in the corresponding PATH column. And also i m not sure about this dummyf, because i have no files named dummyf.
Anyone can help me to bypass this section with datalines option.
Thanks in advance
I do not think your issue has anything to do with INFILE vs DATALINES (ie CARDS).
The name DUMMYF is just a dummy name because the INFILE statement requires a filename even when the actual filename is coming from a dataset variable because of the FILENAME option. Your program is using the variable PN as the name of the file to read. It is getting the value of PN from the variable PROGRAM_NAM that it reads from the dataset SEARCH_HITS.
It looks like PROGRAM_NAM does not contain the path to the file, just the part after the last slash and it is trying to find that file in your current working directory. If you have a path some where (perhaps in PATH or FULL_PATH variable?) then use that when building the variable PN that you are telling the INFILE statement to use. Perhaps you want:
pn = cats('\',path,program_nam);
or
pn = full_path;
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.