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 |
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
0 Response to Generate a new variable by counting character ( "/" )
Post a Comment