Hello Fellow Statalist,

I have a dataset that contains the following vatiables: Date, CIF, FOB, Country and Descriptions (store as string) in excel. I have imported the data into Stata and converted the string vatiable(Description) to numeric using the encode command:

encode Description, gen(Des)

The encode command generates a numeric variable called Des. However, Des(new variable) is a categorical variable so I went on to create a Dummy variable (with multiple indicators) DumDes to allow me sum or total across columns excluding certain indicators in DumDes(another New variable).

gen DumDes=Des

The indicators for DumDes are Exclusion1, Exclusion2, CommonRegime, SpecialRegime1, SpecialRegime2 and they are coded 1, 2, 3, 4, and 5, respectively.

Now with the above Dummy variable (with multiple indicators) I want to fine the total or sum across Column say for CIF. But when computing the sum of CIF I need not to include both Exclusion1 and Exclusion2. In this case how do I obtain the CIF that excludes the two indicators under DumDes?

When I type the codes:

total CIF I get the sum of CIF
total CIF if DumDes==1 I get the sum of CIF less Exclusion1
total CIF if DumDes==2 I get the sum of CIF less Exclusion2
total CIF if DumDes==1&2 It doesn't give me the value I get when I manually add the two Exclusions(1&2) above
total CIF if DumDes !=1&2 Does not give me the actual CIF value.

NB: CIF = Total CIF - indicators Exclusion 1 and Exclusion2.

In short kindly help me with the Stata command for summing across column using the if option.

Many thanks!