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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 677 views
  • 0 likes
  • 2 in conversation