| Date: | Wed, 7 Dec 2005 12:18:01 -0500 |
| Reply-To: | Santosh.Kothamsu@CHASE.COM |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Santosh K <Santosh.Kothamsu@CHASE.COM> |
| Subject: | Re: MkDir Command in SAS |
|
| Content-Type: | text/plain; charset="iso-8859-1" |
Hari,
You might have received bunch of suggestions from the group.
Here's my 2 cents.
You can use the below code as it is with a modification for the directory location.
1) options suppress DOS window.
2) sysfunc checks if the directory already exists, otherwise it makes one.
3) i used sysexec instead of X. The resaon being sysexec can be used conditionally (within an if..then..), whereas X cannot be conditionally executed.
Good luck.
Santosh
options noxwait noxsync;
data _null_;
* Make sure if the directory exists;
%let rc = %sysfunc(fileexist(&newdir));
%if &rc=0 %then %do;
* Make the directory;
%sysexec md &newdir;
%end;
run;
%mend makedir;
%makedir(full directory location);
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@listserv.uga.edu]On Behalf Of Hari
Sent: Wednesday, December 07, 2005 3:09 AM
To: SAS-L@listserv.uga.edu
Subject: MkDir Command in SAS
Hi,
One of the regular SAS'er of this group offered me a solution (personal
mail) to a problem I posted in this group and along the way mentioned
one additonal feature of SAS which is using X command to create
folders.
Like the below code creates a folder by the name "ABCProj" in my
temporary directory.
X 'mkdir %temp%\ABCproj';
(I thought this would be very useful because subsequently I can create
a temp library which can point to above location and keep all the temp
files grouped within a single temp folder. Later depending on my whims
I can use it or delete it.)
I have 2 questions regarding mkdir command and one related to SAS
coding
a) After running this code I get 2 windows one saying "The SAS X
command is active. Enter Exit at the prompt....." and another window is
the DOS prompt which is the active window. I can type exit at the dos
prompt and both the window disappears. Is there any option by which I
can suppress both the windows. Its because I just want to create the
folder and dont want to do anything else with the dos prompt or the
message. My request might make sense becuse I might subsequently write
lots of code following folder creation and would like to get the
resources for running those or it might be possible that am running it
unattended (just pressing F8 and moved over to another workstation for
doing something else). If there is such an option for suppressing the
above 2 windows I would like them to apply for this case only. Its
because I was trying out some code in SAS examples and came across
Sleep function and in that case also similar message is displayed.
Though am not using any sleep function in my case I wouldnt like to
suppress all messages which SAS generates.
b) If I run the mkdir command more than once then the next time around
I dont get any messages saying "such and such folder already exists and
do you want to replace the contents etc". I believ esuch a message
comes if in Windows we already have a folder "A" in path "P" and if I
put/paste another folder with name "A" in path "P". Is such a behaviour
of not displaying warning messge by SAS normal?
d) This is more to do with efficient SAS programming. Lets say I use
the above make directory command in a particular code and have lots of
other mundane code as well. Further I might be running this code lets
say on a daily basis. Since make dir is a one time usage so it doesnt
make sense to include that line on a daily basis (for that particular
computer). I might be having similar codes which is of one time running
usage only (though of a different nature than mkdir) for that
particular computer. So, do folks maintain 2 sets of code files one
which needs to be run only once for that project and another which
needs to be run everytime one wants to run a particulr analysis. (Note
I wouldnt like to delete that one time codes as one should have a
documentation somewhere as to what was done if one is reviewing the
same 6 motnhs from now). But again if I have to give the code to my
colleague then I will have to mail 2 sets of code and explain it to
him/her as to why 2 code files are there etc. I understand that one way
might be to have a single code file and selectively run only those
parts of code which are needed but it is not very robust. Otherwise
with a single code file one may also comment out those parts which dont
need to be run on a daily basis for that comuter. But again if it needs
to be run on a different computer then one needs to uncomment them etc
which is again very.... Are there better solutions?
Regards,
Hari
India
**********************************************************************
This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you
**********************************************************************
|