楼主: mengqinqing
8724 12

关于options的恢复 [推广有奖]

  • 8关注
  • 6粉丝

已卖:1份资源

讲师

94%

还不是VIP/贵宾

-

威望
0
论坛币
64351 个
通用积分
8.0217
学术水平
7 点
热心指数
5 点
信用等级
4 点
经验
21974 点
帖子
468
精华
0
在线时间
650 小时
注册时间
2007-11-24
最后登录
2025-6-4
毕业学校
中山大学

楼主
mengqinqing 发表于 2012-11-30 20:05:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
请问各位大侠,在用通用语句options时设置了nodate nocenter nonumber之后,怎么样一次性恢复这些设置的默认格式?
二维码

扫码加我 拉你入群

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

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

关键词:options Option tions ONS OPT 通用

用自己的力量站在自己的位置

沙发
webgu 发表于 2012-11-30 21:24:44
很可惜,好像没有相关的keywords 如:options reset ;可以一下子搞定。

不过你可以调用这个宏搞定。

%optionreset()


宏定义:  http://blogs.sas.com/content/sas ... sas-system-options/

  1. %macro OptionReset(opt);
  2.   /***************************************************************************
  3.    Created by Mark Jordan - http://go.sas.com/jedi
  4.    August 14, 2012
  5.    This macro is intended to reset any SAS system options which have been
  6.    changed during the SAS session back to the values they had at startup.  
  7.    To see syntax help in the SAS log, submit:
  8.       %SiteCheck(!HELP)
  9.   ***************************************************************************/
  10. %local where;
  11. %if %qupcase(%SUPERQ(opt))=!HELP
  12.    %then %do;
  13.    %PUT ;
  14.    %PUT NOTE:  *&SYSMACRONAME MACRO Documentation *******************************;
  15.    %PUT NOTE-  This macro resets modified SAS system option values back to;
  16.    %PUT NOTE-  the original startup values.;  
  17.    %PUT ;
  18.    %PUT NOTE-  >>>>> Tested on Windows only <<<<<;
  19.    %PUT NOTE-  ;
  20.    %PUT NOTE-  SYNTAX: %NRSTR(%%OptionReset%(<opt>%));
  21.    %PUT NOTE-     opt: standard name of the SAS System option you want to reset;
  22.    %PUT NOTE-     OPTIONAL - if not specified, resets any option with a current;
  23.    %PUT NOTE-                value different from the startup value.;
  24.    %PUT ;
  25.    %PUT NOTE-  Examples: ;
  26.    %PUT NOTE-     To reset only the LINESIZE option:;
  27.    %PUT NOTE-        %NRSTR(%%OptionReset%(LINESIZE%));
  28.    %PUT ;
  29.    %PUT NOTE-     To reset all options:;
  30.    %PUT NOTE-        %NRSTR(%%OptionReset%(%));
  31.    %PUT ;
  32.    %PUT NOTE-  ********************************************************************;
  33.    %RETURN;
  34. %end;

  35.    %if &opt ne %then
  36.    %do;
  37.       /* Normalize the input parameter value */
  38.       %let opt=%qupcase(&opt);
  39.       /* Look up the option name in the dictionary tables */
  40.       proc sql noprint;
  41.          select count(*) into :found
  42.             from dictionary.options
  43.             where optname="&opt"
  44.       ;
  45.       quit;
  46.       %if not &found %then
  47.       %do;
  48.       /* Option not listed in the dictionary tables */
  49.          %put ERROR: (OptionReset Macro) &opt is not a valid SAS option;
  50.          %return;
  51.       %end;
  52.       %else
  53.       %do;
  54.       /* Option WAS listed - select only that option */
  55.          %let WHERE=where optname ="&opt";
  56.       %end;
  57.    %end;
  58.    %else
  59.    %do;
  60.       /* No option specified                                     */
  61.       /* Exclude options you can't change while SAS is executing */
  62.       %let WHERE=where optstart ne 'startup' and optname not in ('AWSDEF','FONT');
  63.    %end;

  64. /* Reset those options that differ from the startup values */
  65. data _null_;
  66.    length statement startup current $1024;
  67.    set sashelp.voption;
  68.    &where;
  69.    startup=getoption(optname,'startupvalue');
  70.    current=getoption(optname);
  71.    if startup ne current then do;
  72.       PUTLOG "NOTE: OptionReset Macro Resetting " optname " from " current " to " startup ".";
  73.       statement =cat('OPTIONS ',getoption(optname,'keyword, startupvalue'),';');
  74.       call execute(statement );   
  75.    end;
  76. run;
  77. %mend;
复制代码

SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

藤椅
mengqinqing 发表于 2012-12-1 09:35:43
webgu 发表于 2012-11-30 21:24
很可惜,好像没有相关的keywords 如:options reset ;可以一下子搞定。

不过你可以调用这个宏搞定。
谢谢!我试了,可是好像没有还原哦~~~
用自己的力量站在自己的位置

板凳
bobguy 发表于 2012-12-2 00:11:07
As simple as below.

options date center number;


报纸
webgu 发表于 2012-12-2 00:39:40
bobguy 发表于 2012-12-2 00:11
As simple as below.

options date center number;
如果改变的OPTION很多,且不一定记得改变了哪些,想一次性恢复到启动时的option,在不重新启动SAS的情况下,有什么更好的方法?
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

地板
webgu 发表于 2012-12-2 00:39:43
bobguy 发表于 2012-12-2 00:11
As simple as below.

options date center number;
如果改变的OPTION很多,且不一定记得改变了哪些,想一次性恢复到启动时的option,在不重新启动SAS的情况下,有什么更好的方法?
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

7
bobguy 发表于 2012-12-2 02:20:58
webgu 发表于 2012-12-2 00:39
如果改变的OPTION很多,且不一定记得改变了哪些,想一次性恢复到启动时的option,在不重新启动SAS的情况下 ...
SAS default or personalized options are effected when SAS is launched. You can use a simple macro records all important ones for later to recover them back.

Here is an example for ls and ps.


*after launch sas using a macro to store all your original options;
%macro myoption;
    PAGESIZE= %sysfunc(getoption(PAGESIZE))
        LINESIZE= %sysfunc(getoption(LINESIZE))
%mend;
%let default_option=options %myoption;
%put "&default_option";

*****change options****;
options ls=120 ps=5000;

proc options GROUP=LISTCONTROL;
run;

***put default option back;
&default_option;

proc options GROUP=LISTCONTROL;
run;
  

8
pobel 在职认证  发表于 2012-12-2 12:12:10
/*Remember the settings of options*/
proc optsave out=opt_save;
run;

/*Change some options*/
options nonumber nodate pagesize=100 nobyline;

/*reset options*/
proc optload data=opt_save;
run;

和谐拯救危机

9
ryuuzt 发表于 2012-12-2 19:11:44
pobel 发表于 2012-12-2 12:12
/*Remember the settings of options*/
proc optsave out=opt_save;
run;
这个好。谢谢。

10
mengqinqing 发表于 2012-12-2 21:26:00
bobguy 发表于 2012-12-2 00:11
As simple as below.

options date center number;
if i don't remenber which option i have changed and need to reset all.....
用自己的力量站在自己的位置

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

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