DATA Step, Macro, Functions and more

File existancy check

Reply
Occasional Contributor
Posts: 9

File existancy check

 

Hello everyone,

I am trying to write the code for following scenario:

1. We have one excel sheet in which there is a column having filenames of .PPT files. All these PPTs are there on some location on the server,

say /sasconf/sasconf/data/PPTs.

2. We want to check that for every record in Excel sheet there exist a file name having exactly the same name provided in every record.

I have tried the following code logic, Which is not helping me. Is there any other logic or SAS function which can help me???

proc import out = proc_mast

datafile= '/sasconf/sasconf/data/department_masters/Process_master.xls'

DBMS = XLS Replace;

sheet = 'Process_MO_Excel_Master';

getnames=yes;

run;

data temp;

set proc_mast(keep = PPT_name);

run;

proc sql noprint;

select count(*) into :cnt from temp;

quit;

proc sql noprint;

select PPT_name into :count0-:count%sysfunc(strip(&cnt))

from temp;

quit;

%macro abc;

data temp11;

%do i=0 %to 35;

%if fileexist("/sasconf/sasconf/data/Data For Configuration/Credit_risk/PPTs/&&count&i..ppt") %then

exist_file=1;

%else

exist_file=0;

output;

%end;

run;

%mend abc;

%abc

Regards,

Rakshit

Respected Advisor
Posts: 3,156

Re: File existancy check

Posted in reply to rakshit_shah

Hi Rakshit,

I have not gone through every single line of your code, but the following seems lacking %sysfunc:

%if fileexist("/sasconf/sasconf/data/Data For Configuration/Credit_risk/PPTs/&&count&i..ppt") %then

instead, you maybe try:

%if %sysfunc(fileexist("/sasconf/sasconf/data/Data For Configuration/Credit_risk/PPTs/&&count&i..ppt")) %then

Regards,

Haikuo

Ask a Question
Discussion stats
  • 1 reply
  • 176 views
  • 0 likes
  • 2 in conversation