BookmarkSubscribeRSS Feed
ani
Calcite | Level 5 ani
Calcite | Level 5

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 Smiley Happy

1 REPLY 1
Tom
Super User Tom
Super User

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;

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
  • 1 reply
  • 827 views
  • 0 likes
  • 2 in conversation