/* One of the things SAS is quirky about is how you are forced to take a different appraoch in summing a column of numbers as opposed to other programming languages. This is because SAS automatically reads the rows or observations for you rather than you providing it with the code to do so like you would in Visual Basic and other languages. In order to sum a column of numbers, you need to use the RETAIN statement */ *First we read in a test data set for you; data mydata; input Y VAR1 VAR2 VAR3; cards; 1 10 33 4 0 20 21 3 1 30 59 2 1 20 76 1 0 . 24 3 0 20 22 2 1 10 28 2 1 10 49 2 0 30 76 2 1 20 59 2 ; *Changing the order of the variables in the dataset is simple, once you know how.; *Simply use a RETAIN statement BEFORE the SET statement with the new order; data test; retain VAR2 VAR3 VAR1 Y; /*put the sum variable after the retain variable and initialize to zero*/ set mydata; run; Title REARRANGING THE ORDER OF VARIABLES IS EASY; proc print data=test;run;