Code:
. list country

     +------------------------------+
     |                      country |
     |------------------------------|
  1. |                           UK |
  2. |                       France |
  3. |     France / Singapore / UAE |
  4. |                  Switzerland |
  5. |                   Spain / US |
     |------------------------------|
  6. |                        Italy |
  7. |                  Switzerland |
  8. |                       France |
  9. |                  Netherlands |
 10. |                           UK |
     |------------------------------|
 11. |  FR / GB / DE / ES / IT / PL |
I would like to generate a new variable, say, number_of_countries, by counting the number of "/" in country. That is, if there is no "/" in country, number_of_countries will be 1; if there is one "/" in country, number_of_countries will be 2, and so on.

For example, for observations 1 and 2 number_of_countries will be 1, and for observation 3 number_of_countries will be 3.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str28 country
"UK"                         
"France"                     
"France / Singapore / UAE"   
"Switzerland"                
"Spain / US"                 
"Italy"                      
"Switzerland"                
"France"                     
"Netherlands"                
"UK"                         
"FR / GB / DE / ES / IT / PL"
end