Make sure that the carpet is free of hair and other debris. This can be accomplished by thoroughly vacuuming the affected area prior to your application of the baking soda mixture.
Combine two tablespoons of baking soda with one cup of warm water. To maximize the effectiveness of this mixture you need to make sure that the baking soda is completely dissolved in the water before using it on the carpet, so take the time to stir it thoroughly.
Pour an appropriate amount of the baking soda mixture on the affected areas of your carpet. You don't want to completely soak your carpet, but it should be wet enough so that the baking soda can penetrate below the surface and neutralize the odor.
Allow the carpet to dry and vacuum over the treated area. Doing this will extract the baking soda granules that have soaked up all of the odor in the carpet. If you can still see white dust after your first few passes with the vacuum then you'll need to continue vacuuming until the carpet is completely clean.
Repeat this process as many times as necessary to completely eliminate the odor. Depending upon the extent of the stain and the depth of the odor you may need to do this more than once to totally remove all of the bad smell. If you need to repeat the process, make sure to let the carpet dry completely in between applications.
Rent a carpet cleaning machine if you aren't successful with the baking soda method. Some stains and odors are too deep and saturated within the carpet to be cleaned with baking soda, and in these instances a carpet steam cleaning machine may be more appropriate. They are generally very cost effective and can be obtained at a number of local hardware stores, so try the homemade solution first and then upgrade to a more powerful method of odor removal if necessary.