Is it proper to integrate an expression containing units? Is it proper to integrate an expression such as $\displaystyle \int \frac 1 {x~\mathrm{J}} \, dx$, where $x$ is in the physical unit of Joules (J)?
The result is $\ln \dfrac x J + \text{constant}$. However, I don't know how to take the natural log of a Joule, or if that is even permitted. My safer approach would be to take the units out of the expression before integrating, by treating the unit expression as a constant:
$$1~J~\int \frac{1}{x~J~(1/J)} \, dt$$
Yet I have been told by a mathematician that this is not necessary. Do you have recommendations to proceed?
 A: It is proper to integrate units, but in physics, you can often guess them at the end. This is probably why you were told it wasn't necessary. Since an integral is a sum of the integrand multiplied by tiny portions of the differential, say $dt$, which would have the unit time. For example, we have  $E=\int_{0}^{t}Pdt$. $E$ is in Joules, $P$ is in  Joules/second, and $dt$ is in seconds. Thus we simply multiply the units of $dt$ by the units of $P$ to get Joules, and everything works out.
As for your example, we have $\int\frac{1}{x}dx$. Since both $x$ and $dx$ are in joules, the Joules unit cancels out and we are left with a dimensionless variable inside the exponent, which is exactly what we want, as it is not correct to take the natural log of a unit, as you yourself stated.
A: It is perfectly proper, and one should bear in mind the units of $dx$. For example, if $f(x)$ is in meters per second and $dx$ is in seconds, the $f(x)\,dx$ is in meters, and so is the integral. So you have
$$
\int \underbrace{\qquad \frac 1 x \qquad}_{\large1/\text{Joules}} \quad \underbrace{\qquad dx \qquad}_{\large\text{Joules}}.
$$
The units cancel and one has a dimensionless quantity.
A: Thank you for all of the answers. Your comments helped cleanup my confusion. 
When integrations are performed in a purely symbolic manner, the units are implied without explicitly stating them. So from a perspective of unit analysis, some integration results don't seem to make sense. However, if one is actually plugging numbers (with units) into the formula, or considering discrete integrals, then those units are explicitly stated, and the results do make sense. Michael Hardy's answer was a good example.
