Date: Mon, 22 May 2000 17:35:24 +0200
Reply-To: Benjamin Guralnik <guralnik@BEZEQINT.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Benjamin Guralnik <guralnik@BEZEQINT.NET>
Subject: SOLUTION: Create a directory from SAS
Content-type: text/plain; charset="windows-1255"
Thanks, Jim.
> So I wrote (compiled) batch files for testing the existence of some name
as
> a file or directory, using attemps to create a dummy file in a directory.
These
> work correctly on all kinds of drives, AFAIK. I have them somewhere at
> home. If you are interested to use them, tell me.
That would be very interesting. Meanwhile, here's a 100% SAS solution that I
found. I'm quite surprised that it can even handle long filenames as well --
%macro mkdir(path);
%let msg = The path &path was successfully created.;
%let pos = 1;
%let token = %scan(&path, &pos, '\');
%let segment =;
%let delim =;
%let op =;
%do %while (&token ne);
%let segment = &segment.&delim.&token;
%let delim = \;
%* put &segment;
%let pos = %eval(&pos + 1);
%let token = %scan(&path, &pos, '\');
%if %sysfunc(fileexist(&segment)) eq 0 %then %do;
%sysexec md &segment;
%* put ERRORCODE &sysrc;
%let op = 1;
/* if the operation failed, display approptiate message
and abort the program */
%if %sysfunc(fileexist(&segment)) eq 0 %then %do;
%let token =;
%let msg = Invalid path name, directory will not be created.;
%end;
%end;
%end;
%if &op = 1 %then %put MKDIR: &msg;
%else %put MKDIR: The path &path does already exist;
%mend;
%mkdir(c:\testdir\anothertest\and_yet_another_one);
Thanks,
Benjamin