To find the perimeter of the rectangular pen, we can use the formula for the perimeter \( P \) of a rectangle, which is given by:
\[ P = 2(a + b) \]
Given that \( a = \frac{1}{3}b \) and that \( a = 12 \), we can substitute \( a \) into the equation for \( b \).
Starting from the equation for \( a \):
\[ a = \frac{1}{3}b \]
Substituting the value of \( a \):
\[ 12 = \frac{1}{3}b \]
To find \( b \), we can multiply both sides by 3:
\[ b = 3 \times 12 = 36 \]
Now we have both dimensions of the pen: \( a = 12 \) yards and \( b = 36 \) yards.
Now we can substitute these values into the perimeter formula:
\[ P = 2(a + b) = 2(12 + 36) \]
Calculating inside the parentheses:
\[ 12 + 36 = 48 \]
Now multiply by 2:
\[ P = 2 \times 48 = 96 \]
Thus, the perimeter of the pen is \( \boxed{96} \) yards.