Hi all,
I have the following
I would like to store in a new string variable the rank&name of the first three (e.g. "1.name 2.name 3.name").
i first tried looping through years something like
but did not work ( I tried also with
into
but not capable to make it works.
Then I did the following:
which resulted into
But I do not understand how to 'concatenate' the three strings vertically.
Many thanks for any advice you may have.
F
I have the following
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str14 region str31 datatype str30 localbrandname byte(rank2015 rank2024) "Western Europe" "Retail Value RSP excl Sales Tax" "Spar" 2 2 "Western Europe" "Retail Value RSP excl Sales Tax" "Total" . . "Western Europe" "Retail Value RSP excl Sales Tax" "Nah & Frisch" 1 1 "Western Europe" "Retail Value RSP excl Sales Tax" "Billa Box" 3 . end
i first tried looping through years something like
Code:
forval i = 2015/2024 { g cr5_list_`i'= "" local list1 = cond(inrange(rank`i', 1, 3), name) replace cr5_list_`i'= "`list1'" }
Code:
if
Code:
local list
Then I did the following:
Code:
foreach var of varlist rank* { tostring `var', g(`var'_str ) } forval i = 2015/2024 { g list`i'=rank`i'_str + "."+ name if inrange(rank`i', 1, 3) }
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str14 region str31 datatype str30 localbrandname byte rank2015 str32 list2015 "Western Europe" "Retail Value RSP excl Sales Tax" "Spar" 2 "2.Spar" "Western Europe" "Retail Value RSP excl Sales Tax" "Total" . "" "Western Europe" "Retail Value RSP excl Sales Tax" "Nah & Frisch" 1 "1.Nah & Frisch" "Western Europe" "Retail Value RSP excl Sales Tax" "Billa Box" 3 "3.Billa Box" end
Many thanks for any advice you may have.
F
Comment