楼主: zhou.wen
7482 39

[原创博文] Using Windows Batch File to Execute SAS Program Efficiently [推广有奖]

已卖:4460份资源

教授

9%

还不是VIP/贵宾

-

TA的文库  其他...

SAS Technology

威望
0
论坛币
31987 个
通用积分
6.2141
学术水平
283 点
热心指数
262 点
信用等级
257 点
经验
56058 点
帖子
396
精华
4
在线时间
1328 小时
注册时间
2010-10-12
最后登录
2018-3-9

初级学术勋章 初级热心勋章 中级学术勋章 中级热心勋章

楼主
zhou.wen 发表于 2013-4-17 14:36:45 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
(Under SAS 9.3  Environment)
SAS users commonly have the need to repeatedly execute sas programs and efficiently perform log scans.we discuss one simple method that uses windows batch(*.bat) files to submit sas program
1. Sample Directory structure


structure.png

2.SAS file(include main.sas & program.sas)
code for main.sas:
  1. %macro Program_initial;
  2. filename fileref pipe "cd";
  3. %put &Root;
  4. data Root;
  5. infile fileref pad;
  6. input Root $200. ;
  7. call symputx('Root',Root);
  8. newdir=dcreate('work',"&Root");
  9. newdir=dcreate('result',"&Root");
  10. run;
  11. libname worklib "&Root/work";
  12. filename result "&Root/result";
  13. %include "&Root/program.sas";
  14. %mend;
  15. %macro Program_Main;
  16. %Program_initial;
  17. ods listing close;
  18. ods html path=result(url=none) file='index.html' ;
  19. /*===============================*/
  20. /*画图全局控制*/
  21. ods graphics on / reset  border=off;
  22. /*===============================*/
  23. %program;
  24. ods html close;
  25. %mend;
  26. %global Root;
  27. %Program_Main;
复制代码
code for program.sas
  1. %macro dataproc;
  2. data worklib.a;
  3. set sashelp.heart ;
  4. run;
  5. %mend;
  6. %macro drawproc;
  7. proc sgpanel data=sashelp.heart noautolegend;
  8.   title "Cholesterol Distribution in Heart Study";
  9.   panelby sex;
  10.   histogram cholesterol;
  11.   density cholesterol;
  12. run;
  13. proc sgscatter data=sashelp.iris;
  14.   title "Scatterplot Matrix for Iris Data";
  15.   matrix sepallength petallength sepalwidth petalwidth
  16.          / group=species;
  17. run;
  18. title;
  19. %mend;
  20. %macro program;
  21. %dataproc;
  22. %drawproc;
  23. %mend;
复制代码
for exmaple:
sasfile_main.png
3.Creating and using sasauto.Bat file
code for  sasauto.bat ,you may need to change the installation path "C:\Program Files\SASHome\SASFoundation\9.3\sas.exe "
  1. @ECHO OFF
  2. SET /P FOLD=Enter Specific Project(i.e. P001)
  3. rem set /p ANALYSIS=Batch Analysis Programs?(Enter Y for yes ,Otherwise hit enter)
  4. rem ECHO Analysis Programs Batch Indicator=%ANALYSIS% >> Batch-Summary.txt
  5. rem set /p GRAPHS=Batch Graph Programs?(Enter Y for yes ,Otherwise hit enter)
  6. rem ECHO Graph Programs Batch Indicator=%GRAPHS% >> Batch-Summary.txt

  7. ECHO Project=%FOLD%>>Batch-Summary.txt
  8. ECHO Start:%DATE%: %TIME%>>Batch-Summary.txt

  9. "C:\Program Files\SASHome\SASFoundation\9.3\sas.exe" -sysin  main.sas  -nolog  -nologo -icon -rsasuser



  10. ECHO End:%DATE%: %TIME%>>Batch-Summary.txt
  11. explorer result\index.html
复制代码
for exmaple
batch.png
4.Run the bat file
(1) Initial Directory Environment
del the file "work" "result" which will recreate by main.sas
double click the sasauto.bat,input your program name and press enter
RunProgram.png
view the result in dir "result/index.html"
result.png
5.check the efficient Efficient.png

本帖隐藏的内容

sastest.rar (1.17 KB, 需要: 1 个论坛币)


二维码

扫码加我 拉你入群

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

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

关键词:EFFICIENT EXECUTE Program Windows Window SAS

已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
crackman + 100 + 100 鼓励积极发帖讨论
webgu + 100 + 100 + 5 + 5 + 5 精彩帖子

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

本帖被以下文库推荐

Practice Is The Best Teacher!

沙发
alfine(未真实交易用户) 发表于 2013-4-17 14:49:37
好文章,顶一下!

藤椅
hamn(未真实交易用户) 发表于 2013-4-17 14:59:20
相当实用

板凳
liuhongming(真实交易用户) 发表于 2013-4-17 14:59:52
支持原创!

报纸
lintorny(未真实交易用户) 发表于 2013-4-17 15:15:08
来看看

地板
admonzhang(未真实交易用户) 发表于 2013-4-17 15:28:10
看起来相当不错,拿下来研究一下

7
zhou.wen(未真实交易用户) 发表于 2013-4-17 16:38:09
inifile.png



Create a directory 'inifile' to  store your initial data would be better

Practice Is The Best Teacher!

8
mosessa(真实交易用户) 发表于 2013-4-17 17:55:11
看看看

9
biyanyidao(未真实交易用户) 发表于 2013-4-17 17:58:24
呢,很好

10
Eternal0601(未真实交易用户) 发表于 2013-4-17 19:05:49
看看

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-4 05:37