全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
6498 6
2010-10-18
逻辑库下存在数据集和文件夹,因为逻辑库在server上面,所以手动上去删除数据很麻烦。
我使用了proc datasets可以把下面的数据集删除,想问问各位高手,怎么可以删除文件夹。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-10-18 22:59:53
X命令
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-10-19 07:44:18
libname aaa "C:\files\test";

*** Get folders under the library;
%let path=%sysfunc(pathname(aaa));
FileName MyDir Pipe "dir ""&path"" /ad /b /s";
data content;
        infile MyDir lrecl=300 truncover;
        input @1 path $100. ;
        format path $100.;
run;
filename mydir clear;

*** Delete all the folders;
data _null_;
     set content;
         filevar=catx(' ',"rmdir",quote(trim(path)));
         infile dummy pipe filevar=filevar end=eof;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-10-19 11:15:21
这里的高手很多啊
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-10-19 13:46:43
3# pobel
高手 能解释下程序?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-10-19 14:04:02
sopching 发表于 2010-10-19 13:46
3# pobel
高手 能解释下程序?
思路是:
1. 用pathname函数找出library的路径;
2. 第一个data步找出该路径下所有的文件夹,并保存完整的路径;
3. 第二个data步利用pipe执行系统命令,删除该路径下的文件夹。

这里主要是利用pipe的机制,本人对pipe也不是很熟悉,只是参照了某个读过的例子。
希望熟悉pipe的高手能解释一下。

下面是一组查找文件夹内容的DATA步,希望对你有点用:
*** What can you do---Get the whole list of options and description;

filename help pipe 'dir /?';
data _null_;
infile help;
input;
list;
run;
filename help clear;

/*
1         Displays a list of files and subdirectories in a directory.
2         
3         DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
4           [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
5         
6           [drive:][path][filename]
7                       Specifies drive, directory, and/or files to list.
8         
9           /A          Displays files with specified attributes.
10          attributes   D  Directories                R  Read-only files
11                       H  Hidden files               A  Files ready for archiving
12                       S  System files               I  Not content indexed files
13                       L  Reparse Points             -  Prefix meaning not
14          /B          Uses bare format (no heading information or summary).
15          /C          Display the thousand separator in file sizes.  This is the
16                      default.  Use /-C to disable display of separator.
17          /D          Same as wide but files are list sorted by column.
18          /L          Uses lowercase.
19          /N          New long list format where filenames are on the far right.
20          /O          List by files in sorted order.
21          sortorder    N  By name (alphabetic)       S  By size (smallest first)
22                       E  By extension (alphabetic)  D  By date/time (oldest first)
23                       G  Group directories first    -  Prefix to reverse order
24          /P          Pauses after each screenful of information.
25          /Q          Display the owner of the file.
26          /R          Display alternate data streams of the file.
27          /S          Displays files in specified directory and all subdirectories.
28          /T          Controls which time field displayed or used for sorting
29          timefield   C  Creation
30                      A  Last Access
31                      W  Last Written
32          /W          Uses wide list format.
33          /X          This displays the short names generated for non-8dot3 file
34                      names.  The format is that of /N with the short name inserted
35                      before the long name. If no short name is present, blanks are
36                      displayed in its place.
37          /4          Displays four-digit years
38         
39        Switches may be preset in the DIRCMD environment variable.  Override
40        preset switches by prefixing any switch with - (hyphen)--for example, /-W.
*/

*** The contents of a folder;
FileName MyDir Pipe 'dir "c:\files" /B';
data content;
infile MyDir lrecl=300 truncover;
input @1 content $100. ;
format content $100.;
run;
filename mydir clear;

*** Only the folders in a directory;
FileName MyDir Pipe 'dir "c:\files\sas\papers" /ad /b ';
data content;
infile MyDir lrecl=300 truncover;
input @1 content $100. ;
format content $100.;
run;
filename mydir clear;

FileName MyDir Pipe 'dir "c:\files"';
data folder;
infile MyDir lrecl=300 truncover;
input @1 folder $100. ;
if index(folder,"<DIR>");
folder=strip(substr(folder,index(folder,"<DIR>")+5));
if folder ne "." and folder ne "..";
put _infile_;
format folder $100.;
run;
filename mydir clear;

*** Get every file(include folders) under a direcotory, down to the root;
FileName MyDir Pipe 'dir "c:\files\sas\papers" /s';
data content;
infile MyDir lrecl=300 truncover;
input @1 content $100. ;
format content $100.;
run;
filename mydir clear;

*** Get every file under the directory, down to the root, and store the full path;
FileName MyDir Pipe 'dir "c:\files\sas\papers" /b /s';
data content;
infile MyDir lrecl=300 truncover;
input @1 content $300. ;
format content $300.;
run;
filename mydir clear;

*** Get all folders under the directory, down to the root;
FileName MyDir Pipe 'dir "c:\files\sas\papers" /ad /b /s';
data content;
infile MyDir lrecl=300 truncover;
input @1 content $300. ;
format content $300.;
run;
filename mydir clear;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群