That is a great function Peter.
On first execution:
14 Data _NULL_;
15 RC = DCreate( "Test1", "C:\Temp");
16 Put "Return code from DCreate is " RC;
17 Run;
Return code from DCreate is C:\Temp\Test1
On second execution:
14 Data _NULL_;
15 RC = DCreate( "Test1", "C:\Temp");
16 Put "Return code from DCreate is " RC;
17 Run;
Return code from DCreate is
So the existence of the directory doesn't seem to put the directory at risk of being replaced which is a robust solution. I especially like the return code which lends itself to being stored in a macro symbol for resolution into a path or file reference elsewhere in the code. I am especially thinking of the situation where the path is derived from some date or calculated parameter, and one need then only calculate it once.
All my path creations are done using a macro that invokes the Windows API CreateDirectoryA which has the benefit of return codes from the Windows OS. These are richer than the Go / NoGo result you get from the SAS SCL functions, including "Already exists" and "Path not found". It also permits defining a security descriptor if you want to. However, it does require some infrastructure.
Kind regards
David
... View more