BookmarkSubscribeRSS Feed
rakshit_shah
Calcite | Level 5

 

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

1 REPLY 1
Haikuo
Onyx | Level 15

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 933 views
  • 0 likes
  • 2 in conversation