It is important to consider the context first. Is this a sandstone, say within the Colorado Plateau? Many of the sedimentary rocks found there are detrital in origin, but there are chemical sedimentary rocks as well (i.e. limestones, evaporites, etc.). There are even volcaniclastic rocks as well. Are you're wondering about the Jurassic Navajo Sandstone or Wingate Sandstone, which are often red, hematitic quartz arenites? These formations were deposited within an eolian sedimentary environment. They were then buried and hosted aquifers. The groundwater originated from the surface and infiltrated through organic-rich sediments. These overlying sediments produced reduced water, dissolving metals such as iron into solution. Later, the groundwater reacted with oxidizing metoric waters, thereby precipitating the iron out of solution. The iron oxide disseminated throughout the formations, but would also concentrate into bands or nodules, called Moki Balls.