Dear all,
I have a string-related problem that I was not able to solve so far. I use Stata 13 MP.
I have string variable "product_code" that, at each date, contains product codes separated by blank spaces
I would like to create dummy variables for each possible product code in my dataset so that I can know at each date which product code was available.
In the example, the dataset I want to obtain looks like
Do you know how I can do that? I tried using -split, but without success.
Many thanks!!
I have a string-related problem that I was not able to solve so far. I use Stata 13 MP.
I have string variable "product_code" that, at each date, contains product codes separated by blank spaces
1 | STATA SAS MATLAB |
2 | R MATLAB |
3 | STATA EXCEL PEN |
In the example, the dataset I want to obtain looks like
date | product code | D_STATA | D_SAS | D_MATLAB | D_R | D_EXCEL | D_PEN |
1 | STATA SAS MATLAB | 1 | 1 | 1 | 0 | 0 | 0 |
2 | R MATLAB | 0 | 0 | 1 | 1 | 0 | 0 |
3 | STATA EXCEL PEN | 1 | 0 | 0 | 0 | 1 | 1 |
Do you know how I can do that? I tried using -split, but without success.
Many thanks!!
Comment