dummy variable for calculating

1 visualización (últimos 30 días)
King To Leung
King To Leung el 5 de Ag. de 2022
Respondida: Walter Roberson el 5 de Ag. de 2022
Hi all,
I have a bunch of sector code in c.sic column (column19). However, there are too many sub sectors and I need to group them to a larger industry. For example, both internet sector (code 123) and microchip sector(code 124) belongs to technology sector. I wanna assign a dummy variable according to the sector code. Like 123 and 124 is A, 234, 255 and 235 is B etc. I wanna have a colum for this. After that I wanna calculate the total return (column 8) for each sector.
Thanks in advance!
  3 comentarios
King To Leung
King To Leung el 5 de Ag. de 2022
I mean like each code like 123 refers to a sub industry/sector. Sub sector is like sub divisions of an industry. Like the sector is manufacturing sector. And there is sub sectors under the industry, like textile, clothing, heavy mental manufacturing etc.
So I wanna group sub sectors together, like sector code 111 123 125 belongs to the same sector and we give it a dummy variable "A".
Jan
Jan el 5 de Ag. de 2022
@King To Leung: It is not clear what your data types are. I do not have any idea about what "code like 123 refers to a sub industry/sector" means. It is not possibloe to suggest some code, as long as you do not clarify with which kind of data you are working.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 5 de Ag. de 2022
Create a list of valid subsector codes, and a corresponding list the same size of the sector each should belong to.
Use the two-output form of ismember() to look up the subsector code to get the index into the table. Use the index to pull out the sector code.
This does not require that the codes are numeric.
If the codes are numeric but include fractional values you should probably use ismembertol()

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by