Problem with procedures

I am struggling with procedures. I know how to write them and know that if I add the procedure to the main program code, it works perfectly. However, I prefer to have some procedures in separate files, since I'd like to use them in different codes. I tried the different ways to do it suggested by Aptech here), but it doesn't seem to work. I created a .g file with the procedure (and with the same name), I saved it in the working directory, but Gauss always gives an error message that it can't find it. I also tried adding the procedure to a library (user.lcg or a library created by myself), but the same thing happens.

What do I do wrong? (I have Gauss 18).

6 Answers


There could be an error in the procedure so that it cannot compile.

The first step is to try and verify that the procedure can run. For example, let's say that I have a file named squareit.g with these contents:

proc (1) = squareit(x);

Then from the GAUSS command line, run the file and if that is successful try and use the procedure.

>> run squareit.g;
>> squareit(4);

Most likely you will get an error when running one of those commands that will give us a hint to the source of the problem. Let us know what happens.


There is no error in the procedure, at least I can run it as you suggest and when it's pasted in the main code, it works perfectly.

It's a simple procedure for data transformation:

proc (1) = data_trasform(x, transform_type);
local x_trans;

if transform_type eq 1;
    x_trans = trimr(x - lag1(x), 1, 0);
elseif transform_type eq 2;
    x_trans = trimr(ln(x) - lag1(ln(x)), 1, 0);



Sorry, I don't know how to paste a code nicely, before it was easy, but I can't find a way now.


Is it possible that the problem is because the procedure name does not match the file name? I think the procedure name, data_trasform, might be misspelled and should be data_transform, instead? Is that correct?


You are absolutely right. I checked this because I thought it could have been the problem, but couldn't detect the missing n. So embarrassing...


We all make silly mistakes from time to time. I am glad we could help you get it resolved.

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 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy