楼主: zy_4613
6429 6

[原创博文] 请问可以使用SAS删除文件夹吗? [推广有奖]

  • 0关注
  • 0粉丝

博士生

86%

还不是VIP/贵宾

-

威望
0
论坛币
688 个
通用积分
37.0032
学术水平
3 点
热心指数
3 点
信用等级
2 点
经验
6593 点
帖子
159
精华
0
在线时间
180 小时
注册时间
2009-9-24
最后登录
2024-3-3

楼主
zy_4613 发表于 2010-10-18 22:44:46 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
逻辑库下存在数据集和文件夹,因为逻辑库在server上面,所以手动上去删除数据很麻烦。
我使用了proc datasets可以把下面的数据集删除,想问问各位高手,怎么可以删除文件夹。
二维码

扫码加我 拉你入群

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

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

关键词:文件夹 datasets dataset Server Serve server 文件夹

回帖推荐

pobel 发表于3楼  查看完整内容

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 du ...

本帖被以下文库推荐

沙发
crackman 发表于 2010-10-18 22:59:53
X命令

藤椅
pobel 在职认证  发表于 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;
已有 3 人评分学术水平 热心指数 信用等级 收起 理由
peijiamei + 1 + 2 学习
soporaeternus + 1 + 1 + 1 我很赞同
hopewell + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 3  热心指数 + 4  信用等级 + 2   查看全部评分

和谐拯救危机

板凳
myzhang1982 在职认证  发表于 2010-10-19 11:15:21
这里的高手很多啊

报纸
sopching 发表于 2010-10-19 13:46:43
3# pobel
高手 能解释下程序?

地板
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;
已有 5 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
a6566792 + 1 + 1 + 1 精彩帖子
sopching + 1 + 1 + 1 相当精彩
crackman + 40 + 1 + 1 精彩帖子
hopewell + 1 + 1 + 1 精彩帖子
soporaeternus + 1 + 1 + 1 好好学习,天天向上

总评分: 论坛币 + 40  学术水平 + 5  热心指数 + 5  信用等级 + 4   查看全部评分

和谐拯救危机

7
zy_4613 发表于 2010-10-19 21:08:01
非常感谢
受教了

这里真的是高手很多啊

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 17:31