sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

SAS Indent : Indent Script for SAS 9.1/9.2/9.3/9.4

 script karma  Rating 23/8, Downloaded by 1111    Comments, bugs, improvements  Vim wiki

created by
Zhenhuan Hu
 
script type
indent
 
description
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;

2. 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;      

3. 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;

4. 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
 
install details
 

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
sas.vim 3.0.1 2017-03-13 7.0 Zhenhuan Hu Fix an issue in indenting macro %end.
sas.vim 3.0.0 2017-03-10 7.0 Zhenhuan Hu Support proper indentation for run-processing procedures.
sas.vim 2.2 2016-08-09 7.0 Zhenhuan Hu Change the behavior how ENDSAS is indented. Now it indents at the same level as the first non-blank line of the program instead of no indent.
sas.vim 2.1 2016-08-08 7.0 Zhenhuan Hu Fix an issue when no indent is made at the end of a macro
sas.vim 2.0 2012-05-09 7.0 Zhenhuan Hu Implemented a brand new algorithm for indenting. Now indenting will be correct with or without close data/proc section by run statement. Added enddata keyword.
sas.vim 1.1 2012-04-30 7.0 Zhenhuan Hu Optimized the indenting approach. Added keyword QUIT.
sas.vim 1.0 2012-04-26 7.0 Zhenhuan Hu Initial upload
ip used for rating: 54.156.92.46

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo