Gerber and Shiu (1997) have studied the joint density of the time of ruin, the surplus immediately before ruin, and the deficit at ruin in the classical model of collective risk theory. More recently, their results have been generalised for risk models where the interarrival density for claims is nonexponential, but belongs to the Erlang family. Here we obtain generalisations of the Gerber-Shiu (1997) results that are valid in a general Sparre Andersen model, i.e. for any interclaim density. In particular, we obtain a generalisation of the key formula in that paper. Our results are made more concrete for the case where the distribution between claim arrivals is phase-type or the integrated tail distribution associated with the claim size distribution belongs to the class of subexponential distributions. Furthermore, we obtain conditions for finiteness of the joint moments of the surplus before ruin and the deficit at ruin in the Sparre Andersen model.