In my experience with dirt and sand or sandy dirt, the sand will go to the bottom of carpeting and be very hard to remove - even with an extractor which I have.
The higher the water lift number of the extractor the better, if it has a 3-stage motor, better.
It takes a LOT of time to very carefully remove embedded dirt, and sometimes, another stiff enough brush to help separate the carpet fibers helps as well.
Or, as Jsmooth above has correctly said, you may have to pull the carpeting all out, and either, run high pressure air through it or better still, a good powerful pressure washer with a Fan type nozzle that will slowly move the embedded layer of dirt from one end of the carpeting to the other and out..
I see this all the time in some floor mats and have to sometimes resort to pressure washing carefully if time permits for drying...
Good luck !
Dan F