Yes, gas can change directly to a solid. This happens through a process called deposition. This process is the exact opposite of sublimation which happens when a solid changes directly into a gas. A great example of deposition is when water vapor changes to ice in the clouds. This occurs due to cold temperatures removing thermal energy from the gas.
Another common example is in regard to fireplaces. When a fire is burning, smoke rises through the chimney. That smoke contains soot which would continue to float up if left uncooled. Whenever the soot makes contact with the sides of the chimney, it automatically turns to a solid and sticks right where it landed.
A gas can change directly into a solid by a process called deposition and this is how frost forms. Water vapor goes straight into the solid state. Water vapor in the sub-freezing air can transform into ice without going through the liquid phase, which is how snow and frost are formed. At very cold temperatures, water can turn directly into ice.
Another example is dry ice, during this phase, a transition at a fixed temperature, a certain amount of heat transfer takes place. This is called latent heat of transition. The direction of this heat transfer can be easily understood by considering the interparticle distance in three phases. In the gas phase, the intraparticle distance is quite large, moderate in a liquid phase, and lowest in a solid phase.