BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dhruvakumar
Obsidian | Level 7

Dear All,

 

Please can you help to provide how to create the Folders in SAS and Rename the folders using the code. 

 

 

Many Thanks

Dhruva 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@dhruvakumar wrote:

Dear KurtBremser,

 

Thanks for advice.If you don't mind can you help one example ...Thanks 


The documentation for each function has examples. Is there something unclear about them?

 

DCREATE()

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p1aj29pf4cxnirn15q5hmf0tv438.htm...

data one;                                                                                                                                     
/* To create a new directory in the UNIX operating environment, using the name                                                                
   that is stored in the variable DirectoryName, follow this form: */                                                                         
                                                                                                                                              
 NewDirectory=dcreate(DirectoryName, '/local/u/abcdef/');                                                                                     
                                                                                                                                              
/* To create a new directory in the Windows operating environment, using the name                                                             
   that is stored in the variable DirectoryName, follow this form: */                                                                         
                                                                                                                                              
NewDirectory=dcreate(DirectoryName, 'd:\testdir\');                                                                                           
                                                                                                                                              
run;

RENAME()

 

Example 1: Renaming Data Sets and Catalog Entries
The following examples rename a SAS data set from Data1 to Data2, and also rename a catalog entry from A.SCL to B.SCL.
rc1=rename('mylib.data1', 'data2');
rc2=rename('mylib.mycat.a.scl', 'b', 'catalog');
Example 2: Renaming an External File
The following examples rename external files.
   /* Rename a file that is located in another directory. */
rc=rename('/local/u/testdir/first',
          '/local/u/second', 'file');
   /* Rename a PC file. */
rc=rename('d:\temp', 'd:\testfile', 'file');
Example 3: Renaming a Directory
The following example renames a directory in the UNIX operating environment.
rc=rename('/local/u/testdir/', '/local/u/oldtestdir', 'file');
Example 4: Renaming a Generation Data Set
The following example renames the generation data set Work.One to Work.Two, where the password for Work.One#003 is my-password.
rc=rename('work.one', 'two',,, 3,'my-password');

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p14axci3mo3egan1okbcydvbt433.htm...

 

I highly suggest bookmarking this page, it's a good organization of functions organized by category

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n01f5qrjoh9h4hn1olbdpb5pr2td.htm...

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

If you are talking about folders (directories) in the file system, look at the dcreate() and rename() functions.

 

If you are talking about SAS metadata folders, look at the METADATA procedure, but using it is NOT trivial.

dhruvakumar
Obsidian | Level 7

Dear KurtBremser,

 

Thanks for advice.If you don't mind can you help one example ...Thanks 

Reeza
Super User

@dhruvakumar wrote:

Dear KurtBremser,

 

Thanks for advice.If you don't mind can you help one example ...Thanks 


The documentation for each function has examples. Is there something unclear about them?

 

DCREATE()

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p1aj29pf4cxnirn15q5hmf0tv438.htm...

data one;                                                                                                                                     
/* To create a new directory in the UNIX operating environment, using the name                                                                
   that is stored in the variable DirectoryName, follow this form: */                                                                         
                                                                                                                                              
 NewDirectory=dcreate(DirectoryName, '/local/u/abcdef/');                                                                                     
                                                                                                                                              
/* To create a new directory in the Windows operating environment, using the name                                                             
   that is stored in the variable DirectoryName, follow this form: */                                                                         
                                                                                                                                              
NewDirectory=dcreate(DirectoryName, 'd:\testdir\');                                                                                           
                                                                                                                                              
run;

RENAME()

 

Example 1: Renaming Data Sets and Catalog Entries
The following examples rename a SAS data set from Data1 to Data2, and also rename a catalog entry from A.SCL to B.SCL.
rc1=rename('mylib.data1', 'data2');
rc2=rename('mylib.mycat.a.scl', 'b', 'catalog');
Example 2: Renaming an External File
The following examples rename external files.
   /* Rename a file that is located in another directory. */
rc=rename('/local/u/testdir/first',
          '/local/u/second', 'file');
   /* Rename a PC file. */
rc=rename('d:\temp', 'd:\testfile', 'file');
Example 3: Renaming a Directory
The following example renames a directory in the UNIX operating environment.
rc=rename('/local/u/testdir/', '/local/u/oldtestdir', 'file');
Example 4: Renaming a Generation Data Set
The following example renames the generation data set Work.One to Work.Two, where the password for Work.One#003 is my-password.
rc=rename('work.one', 'two',,, 3,'my-password');

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p14axci3mo3egan1okbcydvbt433.htm...

 

I highly suggest bookmarking this page, it's a good organization of functions organized by category

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n01f5qrjoh9h4hn1olbdpb5pr2td.htm...

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 5976 views
  • 3 likes
  • 3 in conversation