Measure and mark two pieces of lumber 3 inches longer than the desired height of the closet rod. Use a carpenter's square to draw a perpendicular line across each board at the mark. Trim the boards on the lines using a saw.
Mark one wall 3 or 4 inches above where you plan to install the closet rod. Measure the distance from that point to the wall at the back of the closet. Transfer that measurement to mark the opposite wall.
Vertically stand the boards. Rest the end of one board on the floor against the wall where you intend to hang the closet rod. Align the center of the board to the mark on the wall. Using a drill and bit, drill four evenly spaced holes 8 to 10 inches apart through the board in a vertical line.
Remove the board.
Install a sleeve-type wall anchor in each hole. Repeat the drilling in the opposite wall to make pilot holes and install wall anchors.
Reposition the board on one wall, aligning the pilot holes in the board with the holes in the corresponding wall anchors. Screw the board to the wall with a drill and driving bit. Repeat this procedure with the board on the opposite wall.
Measure and mark 3 inches down from the tops of the installed boards. Mark the transverse center of the boards at this level. Drill a pilot hole through each mark. Install the rod sockets by passing a screw through the bases of the sockets, then screwing them into the pilot holes in the boards.
Measure the distance between the insides of the socket to calculate the length of the closet rod. Subtract 1/4 inch from that length. Measure and mark the closet rod to that dimension. Trim the rod with a saw. Hang the rod between the two sockets.