Hello
I am working on compiling many excel sheets into one file using GAUSS. In some of the sheets I have cells with the following expression:
$$"ER", E100, INVALID CODE OR EXPRESSION ENTERED
which essentially means that there are no data points. I am trying to code this in GAUSS to report it as a missing value. I used the following lines:
data=xlsreadm("filename","b7:b27",1);
data=miss(data,"$$"ER", E100, INVALID CODE OR EXPRESSION ENTERED");
This always reports an error of the form: G0025 : Undefined symbol: 'ER'
I realize that there is something to do with the expression "$$"ER", E100, INVALID CODE OR EXPRESSION ENTERED", but could not correct it. Any help or suggestion is highly appreciated.
Best,
Issam
6 Answers
0
Problem 1
If you imported the data using xlsReadM
, then whatever has been imported is stored in a double-precision floating point value. These "doubles" can only hold 8 bytes, which means a max of 8 characters.
Problem 2
The quotation marks tell GAUSS that you are starting a string. So to represent the literal characters: $$"ER", E100
, you would have to escape the quotes inside the string "$$\"ER\",E100"
.
Diagnosis
First check to see what is actually in those elements. Print them out in the normal way:
print data;
If those elements are printed out as +DEN
, then they have been imported as character data in the matrix. It is also possible that it will print out as some other strange number. To find out what they now represent, use the $
to print it as character data, like this:
print $data;
Now that you see what is there, you can replace it. For example, if prints out as $$"ER",E
, you can replace it with a missing value like this:
err_str = "$$\"ER\",E";
data = miss(data, err_str);
0
Thank you for your prompt reply and helpful comment. It is clear to me now where the issue is. I tried the suggestions and examples you provided and they all worked. But when I applied them to my code, the code runs. It, however, returns a numerical value 1.0491673e-153 instead of a missing value or a dot.
0
What do you see when you do this:
print $data;
0
Thanks again for your reply and suggestion. Yes, when I add the $ sign I get:
$$"ER"
But I thought it should appear as a dot. Can we do that?
Thanks once again for your help.
0
If it is not a dot, then the text in our miss
statement was not correct. Try this:
err_str = "$$\"ER\"";
data = miss(data, err_str);
If you are still having an element which prints out i.e. (print $data
) as $$\"ER\"
, then make sure you are printing out all characters by increasing the print format:
format /rd 12,8;
print $data;
This may show you that you did not see all the characters. If so, adjust your err_str
and run miss
again.
0
Thanks a lot for your help, I really appreciate your prompt replies.
Your Answer
6 Answers
Problem 1
If you imported the data using xlsReadM
, then whatever has been imported is stored in a double-precision floating point value. These "doubles" can only hold 8 bytes, which means a max of 8 characters.
Problem 2
The quotation marks tell GAUSS that you are starting a string. So to represent the literal characters: $$"ER", E100
, you would have to escape the quotes inside the string "$$\"ER\",E100"
.
Diagnosis
First check to see what is actually in those elements. Print them out in the normal way:
print data;
If those elements are printed out as +DEN
, then they have been imported as character data in the matrix. It is also possible that it will print out as some other strange number. To find out what they now represent, use the $
to print it as character data, like this:
print $data;
Now that you see what is there, you can replace it. For example, if prints out as $$"ER",E
, you can replace it with a missing value like this:
err_str = "$$\"ER\",E";
data = miss(data, err_str);
Thank you for your prompt reply and helpful comment. It is clear to me now where the issue is. I tried the suggestions and examples you provided and they all worked. But when I applied them to my code, the code runs. It, however, returns a numerical value 1.0491673e-153 instead of a missing value or a dot.
What do you see when you do this:
print $data;
Thanks again for your reply and suggestion. Yes, when I add the $ sign I get:
$$"ER"
But I thought it should appear as a dot. Can we do that?
Thanks once again for your help.
If it is not a dot, then the text in our miss
statement was not correct. Try this:
err_str = "$$\"ER\"";
data = miss(data, err_str);
If you are still having an element which prints out i.e. (print $data
) as $$\"ER\"
, then make sure you are printing out all characters by increasing the print format:
format /rd 12,8;
print $data;
This may show you that you did not see all the characters. If so, adjust your err_str
and run miss
again.
Thanks a lot for your help, I really appreciate your prompt replies.