SAS Indent


Ⅰ. 插件描述

Indent Script for SAS 9.1/9.2/9.3/9.4

Ⅱ. 基本信息

创建日期:  2012-04-26
使用用户:  1
Github星:  1
插件作者:  Zhenhuan Hu

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin '/sas-indent'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle '/sas-indent'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug '/sas-indent'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/vim-scripts/SAS-Indent

Ⅳ. 文档说明

Indent script for SAS. The algorithm is supposed to be rather tolerable.

Examples of the indenting results are shown as following:

  1. For data step/proc sections, the script can properly indent with or without the closing run/quit statements.
       (SAS does not require explicit closing statements for data step/proc sections.)

   data female;
      set total; where gender = 0;
   data male;
      set total; where gender = 1;
   run;
   proc sort data = new; by gender;
   proc freq data = new;
      table gender / missing;
   endsas;

  1. The script can also recognize which procedure supports run-processing and indent accordingly.

   proc reg;
      model y = x1-x5;
   run;
      model y = x1-x10;
   run;
   quit;      

  1. The indentation is properly managed when mixed with macros.
       (Nesting macro is evil. Don't do it)

   %macro test();
      data new;
         set old; where age >= 18;
         format gender gender.;
      proc freq;
         table gender;
   %mend;

  1. Logic expressions.

   data a;
      set b; where age >= 18;
      if numtx = 1 and not (pid > 0 and dcitag in (1, 2)) then strata = 3;
      else if pid > 0 then do;
         if dcitag in (1, 2) then do;
            strata = 1; dcitype = 1;
         end;
         else if dcipsh1 = 1 then do;
            strata = 1; dcitype = 3;
         end;
         else if numtx > 1 then strata = 2;
      end;
      else do;
         if dcitag2 in (1, 2) then do; strata = 1; dcitype = 2; end;
         else if dcipsh1 = 1 then do; strata = 1; dcitype = 3; end;
         else if pid < 0 and dcipsh1 ~= 1 and numtx > 1 then strata = 2;
      end;
   run;

Please also check out my SAS syntax script: http://vim.sourceforge.net/scripts/script.php?script_id=3522

添加新评论