BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
acordes
Rhodochrosite | Level 12

My starting point is the following:

 

The data _null_ works as expected, but the filename line gives an error, if the folder does not exist. 

How can I wrap it in an %if %then statement? How can I check for the existence of the folder?

 

filename myfolder FILESRVC FOLDERPATH= "/Reporting/DEV/REG/ABCD/out_json_backup";

data _null_;
  dir_id=exist("myfolder");
  if dnum(dir_id)=0 then do;
       /* do what is necessary if folder is empty */
%put 'hello';
    end;
  rc=dclose(dir_id);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Please check the docs!

  • exist can be used with datasets and views only
  • before using dnum and dclose you need to use dopen

 

View solution in original post

1 REPLY 1
andreas_lds
Jade | Level 19

Please check the docs!

  • exist can be used with datasets and views only
  • before using dnum and dclose you need to use dopen

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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