Fun With The Fun King: The SASĀ® Solution to the Magic Square

Frank Ferriola
Charles Schwab


My father introduced me to the "Magic Square" as a 3x3 or other odd numbered square in which you could place the integers from 1 to (n*n) and have all rows, across, down and diagonally equal the same number.

In 2001, I included the concept of the Magic Square in a presentation at WUSS, and how my father taught me a simple pattern that solved it in seconds. In 2005, I presented the Manual Solution to the Magic Square.

In this paper I present the SAS(R) solution to the problem, which will take you through all the rules that get applied to solve for any square that has an odd number of rows and columns.