Hello,
I am very much new to STATA and would like to ask for your help in reshaping the data (Forgive me if my explanation is not sufficient or poor for you to understand). I have India's tariff data by years (2020-2017) listed by 8 digits of Harmonized System 2017 + additional two digits of dutytypecode. I'm trying to reshape the data by creating new columns for each year if the values match the 8 digits of the HS code (Please note that each year has a shorter and a longer list of 8 digits codes, so each year's data will not perfectly match with other years) and list the data that does not match with other years at the end of each year's list.
The original data goes like this:
Year TL (<--8digit code) DutyTypeCode AVDutyRate
2020 XXXXXXXX 02 30
2020 XXXXXXXX 50 0
2020 YYYYYYYY 02 30
2020 YYYYYYYY 50 0
. . .
. . .
. . .
2019 XXXXXXXX 02 30
2019 XXXXXXXX 50 0
2019 YYYYYYYY 02 30
2019 YYYYYYYY 50 0
2019 ZZZZZZZZ 02 20
2019 ZZZZZZZZ 50 0
. . .
. . .
. . .
2018 XXXXXXXX 02 30
2018 XXXXXXXX 50 0
What I want the data to be:
TL DutyTypeCode AVDutyRate20 AVDutyRate19 AVDutyRate18 AVDutyRate17
XXXXXXXX 02 30 30 30 30
XXXXXXXX 50 0 0 0 0
YYYYYYYY 02 30 30 - 0
YYYYYYYY 50 0 0 - 0
ZZZZZZZZ 02 - 20 - -
ZZZZZZZZ 50 - 0 - -
I'm also adding a screenshot of my browser window. I have created new variables for each year already but show the value in that year.

Thank you for your help in advance!
I am very much new to STATA and would like to ask for your help in reshaping the data (Forgive me if my explanation is not sufficient or poor for you to understand). I have India's tariff data by years (2020-2017) listed by 8 digits of Harmonized System 2017 + additional two digits of dutytypecode. I'm trying to reshape the data by creating new columns for each year if the values match the 8 digits of the HS code (Please note that each year has a shorter and a longer list of 8 digits codes, so each year's data will not perfectly match with other years) and list the data that does not match with other years at the end of each year's list.
The original data goes like this:
Year TL (<--8digit code) DutyTypeCode AVDutyRate
2020 XXXXXXXX 02 30
2020 XXXXXXXX 50 0
2020 YYYYYYYY 02 30
2020 YYYYYYYY 50 0
. . .
. . .
. . .
2019 XXXXXXXX 02 30
2019 XXXXXXXX 50 0
2019 YYYYYYYY 02 30
2019 YYYYYYYY 50 0
2019 ZZZZZZZZ 02 20
2019 ZZZZZZZZ 50 0
. . .
. . .
. . .
2018 XXXXXXXX 02 30
2018 XXXXXXXX 50 0
What I want the data to be:
TL DutyTypeCode AVDutyRate20 AVDutyRate19 AVDutyRate18 AVDutyRate17
XXXXXXXX 02 30 30 30 30
XXXXXXXX 50 0 0 0 0
YYYYYYYY 02 30 30 - 0
YYYYYYYY 50 0 0 - 0
ZZZZZZZZ 02 - 20 - -
ZZZZZZZZ 50 - 0 - -
I'm also adding a screenshot of my browser window. I have created new variables for each year already but show the value in that year.
Thank you for your help in advance!
Comment