Original data has a string variable "country"
country
US
US
UK
US
Canada
UK
US
Canada
To reduce file size, I want to turn this into a numeric variable, something like
country
1
1
2
1
3
2
1
3
while also separately saving a file correspondence.dta that looks like
numeric country
1 US
2 UK
3 Canada
Changing it to numeric to reduce the file size could be done by doing this.
encode country, gen(country2)
drop country
gen country3=country2
drop country2
rename country3 country
But since I am using country3, but not country2 (which has string label), this data now do not contain string information that I need although file size has been successfully reduced.
I need that correspondence.dta file.
How can I generate that while also simultaneously reducing file size like this?
country
US
US
UK
US
Canada
UK
US
Canada
To reduce file size, I want to turn this into a numeric variable, something like
country
1
1
2
1
3
2
1
3
while also separately saving a file correspondence.dta that looks like
numeric country
1 US
2 UK
3 Canada
Changing it to numeric to reduce the file size could be done by doing this.
encode country, gen(country2)
drop country
gen country3=country2
drop country2
rename country3 country
But since I am using country3, but not country2 (which has string label), this data now do not contain string information that I need although file size has been successfully reduced.
I need that correspondence.dta file.
How can I generate that while also simultaneously reducing file size like this?
Comment