May 2012 Quick Tips

Quick Tip #1: Auto Arrange Feature in Enterprise Guide: Organizing Your Process Flow

Quick Tip #2:  Referencing All Elements in an Array

 

Quick Tip #1: Auto Arrange Feature in Enterprise Guide: Organizing Your Process Flow

 

SAS Enterprise Guide is great at making assumptions and doing things automatically for the user.  Of course, sometimes the user needs to know how to override the software. 

One example of this is in how EG arranges the items in the Process Flow.  EG automatically arranges the items in the Process Flow as they are developed.  Here is a sample screenshot:

 

 

Sometimes it can get messy and confusing—especially as more and more items are added.  So, the user can turn off the “Auto Arrange” feature.  This is done by simply right clicking on the process flow and de-selecting “Auto Arrange.” 

 

 

The user can then drag and drop the items in the Process Flow however they like:

 

 

 

Quick Tip #2: Referencing All Elements in an Array 

 

Here is a small feature we learned at SAS Global Forum.

 

Arrays are great for grouping like values in a row and indexing through those values.

 

For example, if we have ten values with various names and we would like to sum all the values up and then display all the values in the SAS log, the following program does that with arrays and looping. 

 

data sample;

input x1 balance payment x2 x3 x4 x5 x6 x7 x8;          /* read variables  */

array allx{10} x1 balance payment x2 x3 x4 x5 x6 x7 x8; /* define array    */

do i=1 to 10;                                           /* loop thru array */

 sumall=sum(sumall,allx{i});                           /* accumulate sums */

 putlog allx{i}= @;                                    /* display element */

end;                                                    /* end of loop     */

putlog sumall=;                                         /* display summall */

datalines;

1 200 100 2 3 4 5 6 7 8

1 300 150 7 9 8 7 6 5 4

;

run;

 

x1=1 balance=200 payment=100 x2=2 x3=3 x4=4 x5=5 x6=6 x7=7 x8=8 sumall=336

x1=1 balance=300 payment=150 x2=7 x3=9 x4=8 x5=7 x6=6 x7=5 x8=4 sumall=497

 

 

If we want to refer to all elements in an array, we can use the * element to refer to all elements in statements where that makes sense.

Those statements are INPUT, PUT, PUTLOG, and functions that accept elements in any order.

So to perform the task shown earlier, we can simply use the array{*} notation in our program and eliminate the looping.

 

 

 

data sample;

array allx{10} x1 balance payment x2 x3 x4 x5 x6 x7 x8; /* define array     */

input allx{*};                                          /* read all elements*/

sumall=sum(of allx{*});                                 /* sum all elements */

putlog allx{*}= sumall=;                                /* print everything */

datalines;

1 200 100 2 3 4 5 6 7 8

1 300 150 7 9 8 7 6 5 4

;

run;

 

x1=1 balance=200 payment=100 x2=2 x3=3 x4=4 x5=5 x6=6 x7=7 x8=8 sumall=336

x1=1 balance=300 payment=150 x2=7 x3=9 x4=8 x5=7 x6=6 x7=5 x8=4 sumall=497