Hello everyone,
My dataset is for the years 1998 to 2023. It has 20 counties. Each county has several districts with their names (District_name) and numbers (District_no). I want to assign district names for the year 2023 to district names from 2022 to 1998. So, all districts with the same district number within a given county will have the same name, which is their name for the year 2023.
I tried the following code. But it is correct.
sort County District_no ( District_name) Year
by County District_no ( District_name) Year: generate name_2023 = District_name if Year == 2023
by County District_no ( District_name) Year: replace District_name = min_2023 if Year >= 1998 & Year <= 2022
Thanks in advance
data
My dataset is for the years 1998 to 2023. It has 20 counties. Each county has several districts with their names (District_name) and numbers (District_no). I want to assign district names for the year 2023 to district names from 2022 to 1998. So, all districts with the same district number within a given county will have the same name, which is their name for the year 2023.
I tried the following code. But it is correct.
sort County District_no ( District_name) Year
by County District_no ( District_name) Year: generate name_2023 = District_name if Year == 2023
by County District_no ( District_name) Year: replace District_name = min_2023 if Year >= 1998 & Year <= 2022
Thanks in advance
data
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str11 County str8 District_no str55 District_name float Year double Gross_tax_rate "adams" "1" "north blue creek township" 1998 7.0968 "adams" "1" "north blue creek township" 1999 6.8312 "adams" "1" "north blue creek township" 2000 7.0852 "adams" "1" "north blue creek township" 2001 7.4966 "adams" "1" "north blue creek township" 2002 2.6538 "adams" "1" "north blue creek township" 2004 1.8515 "adams" "1" "north blue creek township" 2005 2.0251 "adams" "1" "north blue creek township" 2006 2.1824 "adams" "1" "north blue creek township" 2007 1.8156 "adams" "1" "north blue creek township" 2008 2.0141 "adams" "1" "north blue creek township" 2009 . "adams" "1" "north blue creek township" 2010 . "adams" "1" "north blue creek township" 2011 . "adams" "1" "north blue creek township" 2012 . "adams" "1" "north (blue) creek township" 2013 . "adams" "1" "north blue creek township" 2014 . "adams" "1" "north blue creek township" 2015 . "adams" "1" "north blue creek township" 2016 . "adams" "1" "north blue (creek) township" 2017 . "adams" "1" "north blue creek township" 2018 . "adams" "1" "north blue creek township" 2019 . "adams" "1" "north blue/creek township" 2020 . "adams" "1" "north blue creek township" 2021 . "adams" "1" "north blue creek township" 2022 . "adams" "1" "north blue creek township" 2023 . end