Hello,
This is one of my first attempt to create a mata function... And this is also my first post here.
I have several xlsx files with data from 2000 to 2014. I am doing some mata operations from these different sets. I am stuck at the very beginning of my code... As I cannot create a function that returns the matrix I want:
However, the code returns the following error:
just after b.load_book("2014_m2.xlsx")
I do not understand what I am doing wrong here... When I try to directly import the data, it works perfectly but as soon as I introduce these peaces of code in a matrix... Error! I would appreciate a lot some guidances.
Thank you very much,
Charles.
This is one of my first attempt to create a mata function... And this is also my first post here.
I have several xlsx files with data from 2000 to 2014. I am doing some mata operations from these different sets. I am stuck at the very beginning of my code... As I cannot create a function that returns the matrix I want:
Code:
mata: mata drop test() mata real matrix test(scalar year) //the output will be a matrix so I type "real matrix" { real matrix Z real scalar N, K, I, C N = 42 K = 20 I = 2 C = 5 b=xl() // excel file loaded tool b.load_book("2014_m2.xlsx") // i identify the workbook from where i want to import b.set_sheet("sheet1") // i identify the spreadsheet Z=b.get_number((4,4+N*K*I-1),(4,4+N*K*I-1)) //import the matrix return(Z) } end mata: test(2014)
type mismatch: exp.exp: transmorphic found where struct expected
r(3000);
r(3000);
Code:
: real matrix test(scalar year) > { > real matrix Z > real scalar N, K, I, C > N = 42 > K = 20 > I = 2 > C = 5 > b=xl() > b.load_book("2014_m2.xlsx") type mismatch: exp.exp: transmorphic found where struct expected r(3000);
I do not understand what I am doing wrong here... When I try to directly import the data, it works perfectly but as soon as I introduce these peaces of code in a matrix... Error! I would appreciate a lot some guidances.
Thank you very much,
Charles.
Comment