Discussion:
Possible to create a folder (in Windows) from SAS?
(too old to reply)
Norris, Paul
2009-09-15 18:47:23 UTC
Permalink
I'd like to programmatically create a destination folder for jobs that appe=
nds the datetime to the name of the folder.

Is it possible to create a folder in Windows from SAS and give it a name ge=
nerated in the SAS program?

Thanks,

Paul Norris
UCSF
Joe Matise
2009-09-15 18:54:19 UTC
Permalink
Yep.

x "md <directory name>"; (and of course use whatever macro variable in that
you want).

Use OPTION NOXWAIT, also.

-Joe
Post by Norris, Paul
I'd like to programmatically create a destination folder for jobs that
appends the datetime to the name of the folder.
Is it possible to create a folder in Windows from SAS and give it a name
generated in the SAS program?
Thanks,
Paul Norris
UCSF
v***@gmail.com
2017-12-14 18:58:44 UTC
Permalink
Post by Joe Matise
Yep.
x "md <directory name>"; (and of course use whatever macro variable in that
you want).
Use OPTION NOXWAIT, also.
-Joe
Post by Norris, Paul
I'd like to programmatically create a destination folder for jobs that
appends the datetime to the name of the folder.
Is it possible to create a folder in Windows from SAS and give it a name
generated in the SAS program?
Thanks,
Paul Norris
UCSF
This is a easy way for it
%Macro Verifica_Lib(Libreria,Ruta);
Data _Null_;
Call Symput('Destino',&Ruta||Compress('&Libreria'));
Run;
%Put &Destino;
%If (%SysFunc(LibRef(&Libreria))) Ne 0 %Then %Do;
%Put Verificando existencia de libreria;
%Put La libreira &Libreria No Existe;
%Put Se procederaa crearla;
Options DLCreateDir;
LibName &Libreria "&Destino";
%End;
%Else %Do;
%Put Verificando existencia de libreria;
%Put La libreira &Libreria existe;
%Put Se continuara el proceso;
%End;
%Error_Sas(Verificacion de Libreria local);
%MEnd Verifica_Lib;

Shankar
2009-09-15 19:37:25 UTC
Permalink
It might be better to do this using the function DCREATE;

data _null_;

length test $32;

/* test can be a data set variable */

test=strip('test1_' !! put(today(),best.));

NewDirectory=dcreate(test,'/local/u/abcdef/');

run;

If directory could not be created then NewDirectory would be empty;
Please see documentation;

thanks,
Shankar
Adolfo Lopez
2009-09-15 19:05:57 UTC
Permalink
Yes, the following command will create a directory using a macro variable.
You can define the variable in you SAS program prior to submitting this
line of code. FYI, this is submitted outside of the data step.


x mkdir &dirnam.;

Adolfo Lopez | Discover
Project Manager, Analysis & Pricing
2500 Lake Cook Road, Riverwoods, IL 60015
P: 224.405.5328 F: 224.405.4971 ***@discover.com



"Norris, Paul" <***@UCSF.EDU>
Sent by: "SAS(r) Discussion" <SAS-***@LISTSERV.UGA.EDU>
09/15/2009 01:54 PM
Please respond to
"Norris, Paul" <***@UCSF.EDU>


To
SAS-***@LISTSERV.UGA.EDU
cc

Subject
Possible to create a folder (in Windows) from SAS?






I'd like to programmatically create a destination folder for jobs that
appends the datetime to the name of the folder.

Is it possible to create a folder in Windows from SAS and give it a name
generated in the SAS program?

Thanks,

Paul Norris
UCSF




Please consider the environment before printing this email.
Nathaniel Wooding
2009-09-15 19:21:54 UTC
Permalink
I have never used it but there is the V9 function

DCREATE (dirname,<pdir>) creates directory dirname under current working
directory or parent directory pdir; returns full pathname if
successful, null string if unscuccessful
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
Kevin Viel
2009-09-18 13:36:16 UTC
Permalink
Post by Norris, Paul
I'd like to programmatically create a destination folder for jobs that
appends the datetime to the name of the folder.
Is it possible to create a folder in Windows from SAS and give it a name
generated in the SAS program?
Surely. In fact, I created an ugly macro for my Windows box:



%Macro DCreate ( Path = ) ;

Data _null_ ;

Length Path $ 500
Folder $ 100
;

Path = Scan( "&Path." , 1 , "\" ) ;

Do _n_ = 2 To CountC( "&Path." , "\" ) + 1 ;
Folder = Scan( "&Path." , _n_ , "\" ) ;
RC = DCreate( Folder , Path ) ;
Path = CatS( Path , "\" , Folder ) ;
If RC ne " " then put RC= ;
End ;

Run ;

%MEnd DCreate ;

HTH,

Kevin
Joe Whitehurst
2009-09-18 14:58:12 UTC
Permalink
V6 docs not available online, but V8 is: http://v8doc.sas.com/sashtml/ and
DCREATE is documented there.
Actually, DCREATE is a SAS Component Language function that has been around
since V6 in the early 1990's
On Tue, Sep 15, 2009 at 3:21 PM, Nathaniel Wooding <
Post by Nathaniel Wooding
I have never used it but there is the V9 function
DCREATE (dirname,<pdir>) creates directory dirname under current working
directory or parent directory pdir; returns full pathname if
successful, null string if unscuccessful
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
Joe Whitehurst
2009-09-18 14:35:54 UTC
Permalink
Actually, DCREATE is a SAS Component Language function that has been around
since V6 in the early 1990's

On Tue, Sep 15, 2009 at 3:21 PM, Nathaniel Wooding <
Post by Nathaniel Wooding
I have never used it but there is the V9 function
DCREATE (dirname,<pdir>) creates directory dirname under current working
directory or parent directory pdir; returns full pathname if
successful, null string if unscuccessful
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
Nathaniel Wooding
2009-09-18 15:02:26 UTC
Permalink
Joe

I'm not surprised that it has been around longer than V9.

I based my V9 comment on its being flagged as a V9 function in my copy of T=
S486 but since I have augmented TS486, I may also have introduced a typo or=
two.

Thanks for the correction.

Nat

From: Joe Whitehurst [mailto:***@gmail.com]
Sent: Friday, September 18, 2009 10:58 AM
To: Nathaniel Wooding (Services - 6)
Cc: SAS-***@listserv.uga.edu
Subject: Re: Possible to create a folder (in Windows) from SAS?

V6 docs not available online, but V8 is: http://v8doc.sas.com/sashtml/ and =
DCREATE is documented there.
On Fri, Sep 18, 2009 at 10:35 AM, Joe Whitehurst <***@gmail.com<m=
ailto:***@gmail.com>> wrote:
Actually, DCREATE is a SAS Component Language function that has been around=
since V6 in the early 1990's

On Tue, Sep 15, 2009 at 3:21 PM, Nathaniel Wooding <***@dom.c=
om<mailto:***@dom.com>> wrote:
I have never used it but there is the V9 function

DCREATE (dirname,<pdir>) creates directory dirname under current working
directory or parent directory pdir; returns full pathname if
successful, null string if unscuccessful
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
Loading...