sponsor Vim development Vim logo Vim Book Ad

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

 script karma  Rating 14/5, Downloaded by 454    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 section and procedure, proper indenting would be applied, with or without closing the section by run/quit statement.

   data female;
         set total; where gender = 0;
   data male;
         set total; where gender = 1;
   run;
  
   data new;
         set female male;
   run;

   proc sort data = new;
         by gender;
   proc freq data = new;
         table gender / missing;
   endsas;

2. Even mixed with macro, the indenting is correct.

   %macro temp();
         data new;
               where age >= 18;
               format gender gender.;
         proc freq data = new;
               table gender / missing;
   %mend; * Without closing by run statement;

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

PS: It should also work very well with my SAS syntax file: http://vim.sourceforge.net/scripts/script.php?script_id=3522
 
install details
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
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.235.51.243

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