How to name the imported excel data set?

Thank you for your reply to my last question. As I told you in my last question, I have 8 variables for 40 countries over 1989-2012. I have two related questions I need clarification on:
(1).Can I import the data for the full sample at once? Or do I have to import separate files for each variable and merge inside the Gauss workspace, if merging is possible? For instance, A1 contains Year, B1-F1 contain Credit data (B1 for AUS, C1 for BEL, D1 for DEU, E1 for SWE, and F1 for NOR), G1-K1 Saving data (for those five countries); L1-P1 Investment data for the five countries...(I actually have 40 countries and 8 variables). Can I import the full dataset at once? or do I have to import separate files for each variable: for CREDIT, SAVING, INVESTMENT,etc? When I specify data range as, say, B2:P30, only the cells with numeric values show up in Gauss.
(2) Once I have the data in Gauss, how can I name them? For instance, B1 as Credit_AUS, C1 as Credit_BEL,...F1 as Credit_NOR; G1 as Saving_AUS,H1 as Saving_BEL,...K1 as saving_NOR, L1 as INV_AUS,...P1 as INV_NOR,...?

1 Answer


1. If you use the function spreadSheetReadM or xlsReadM, GAUSS will read the data into a GAUSS matrix. GAUSS matrices are numeric.

In most cases, you should read string data in as a string array. See #2 below. You can, however, place text inside of matrix elements if you want, but : a) it will be limited to 8 characters per element and to print it you will need to use the $. For example:

d = { 1.1, 2.2, 3.3 };
s = "GDP" $| "EXPORTS" $| "INFLATION";

//write numeric data to A2:A4 in new xls file
ret = xlsWriteM(d, "test.xls", "A2", 1, "");

//write string data to B2:B4 in 'test.xls'
ret = xlsWriteSA(s, "test.xls", "B2", 1, "");

//read in all data as a matrix
my_mat = xlsReadM("test.xls", "A2:B4", 1, "");

//Print out numeric column
print my_mat[.,1];

//Print out character column
print $my_mat[.,2];

2. If you want to read in string data that will stay as strings, you should use either spreadSheetSA or xlsReadSA.

3. If you want to have a GAUSS variable for each column in your
dataset, you can simply assign a new variable after you load the column. For example after we loaded all the data into my_mat as in the above example, you could just do this:

my_new_var = my_mat[.,1];

Also if you want to load in all of the columns as separate GAUSS variables, you can look at this tutorial.
However, since you are probably going to be doing matrix math, you might want to reconsider whether you want to break up the matrix into one column vector for each model variable.



Your Answer

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy