I need to export from Matlab to Stata an array of numbers and strings.
For example:
clear
r=2;
n=4;
X=unifrnd(0,1,r,n);
X_STATA=reshape(X.', r*n,1);
id_STATA=kron((1:1:r).', ones(n,1));
mode_STATA=repmat(["AIR"; "TRAIN"; "BUS"; "CAR"],r,1);
Here, I want to export X_STATA
, id_STATA
and mode_STATA
.
How can I do this?
In particular, I want to make sure that the numbers after the comma of the entries of X_STATA
are well exported, without inappropriate approximations.
In Matlab you can do the following:
writematrix(X_STATA, 'myfile.csv', 'precision', 17)
In Stata you import the data like this:
import delimited myfile.csv, asdouble
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments