I have a large number of datasets that contain 30+ of the same variables. I am attempting to append all datasets although the problem is that in one dataset a given variable is a string variable while in another dataset that same variable is a byte variable.
Take the snippet below as an example: In this data set (let's call it dataset 1) has_study, has_separatedining, has_familyroom , has_sunroom and has_rumpusroom are string variables while has_billiardroom is a byte variable. However, in dataset 2, has_billiardroom is now a string variable and perhaps has_study is now a string variable also. How do I efficiently transform all the data into the same type so that I can then append datasets?
The datasets will append only if I use the 'force' command however I lose data.
Array
I know I can convert strings to numeric variables using:
gen study = 0
replace study=1 if has_study=="TRUE"
However, given that I have such a large number of datasets and variables, this is very inefficient. I would like to run the same do.file for each dataset. Is there another way around this issue?
Related Posts with How do I make multiple variables in each dataset the same 'type' in order to append datasets and avoid losing data?
Make panel dataHello Statalist! I want to make panel data from this: ID roa2009 roa2010 roa2011 roa2012 bis2009 …
Generating New Variable As A Function of Group-Level Differences Of Another VariableHello All, and Thanks in Advance. I have a very large dataset for which I need to create a variable…
"assert inrange(var1,1,5)" and "assert inrange(var1,1,5)&!missing(var1)"What's the difference between "assert inrange(var1,1,5)" and "assert inrange(var1,1,5)&!missing(…
rifreg and oaxaca8 error In order to analyze gender wage gap, the following is conducted. However, It is impossible to proce…
repeatedly getting error when trying to create a panel "repeated time values within panel r(451)"I have the following data type. I have four countries with 50 companies each for three years. I was …
Subscribe to:
Post Comments (Atom)
0 Response to How do I make multiple variables in each dataset the same 'type' in order to append datasets and avoid losing data?
Post a Comment