<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>undefined symbol &#8211; Aptech</title>
	<atom:link href="https://www.aptech.com/blog/tag/undefined-symbol/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aptech.com</link>
	<description>GAUSS Software - Fastest Platform for Data Analytics</description>
	<lastBuildDate>Tue, 23 Apr 2024 19:55:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Understanding Errors &#124; G0025 : Undefined symbol</title>
		<link>https://www.aptech.com/blog/understanding-errors-g0025-undefined-symbol/</link>
					<comments>https://www.aptech.com/blog/understanding-errors-g0025-undefined-symbol/#respond</comments>
		
		<dc:creator><![CDATA[aptech]]></dc:creator>
		<pubDate>Fri, 23 Apr 2021 18:21:41 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[undefined symbol]]></category>
		<guid isPermaLink="false">https://www.aptech.com/?p=11581214</guid>

					<description><![CDATA[Today we will help you to understand and resolve <code>Error G0025: Undefined symbol</code> We will answer the questions:
<ol>
<li> What is a GAUSS symbol</li>
<li> What are the most common types of GAUSS symbols?</li>
<li>How do I define a GAUSS symbol?</li>
<li> How do I resolve the error `G0025: Undefined symbol`?</li>
</ol>]]></description>
										<content:encoded><![CDATA[<h3 id="introduction">Introduction</h3>
<p>Today we will help you to understand and resolve <code>Error G0025: Undefined symbol</code>. We will answer the questions:</p>
<ul>
<li>What is a GAUSS symbol?</li>
<li>What are the most common types of GAUSS symbols?</li>
<li>How do I define a GAUSS symbol?</li>
<li>How do I resolve the error <code>G0025: Undefined symbol</code>?</li>
</ul>
<h2 id="what-is-a-symbol">What is a symbol?</h2>
<p>In GAUSS a symbol is a label used to represent some data, a procedure or function. For example, in the code below:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">a = 3;
b = 4;</code></pre>
<p><code>a</code> and <code>b</code> are symbols representing the scalar values 3 and 4 respectively.</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">c = a + b;

d = 3 + 4;</code></pre>
<p>The above code creates two new symbols, <code>c</code> and <code>d</code>.</p>
<ul>
<li><code>c</code> is created by applying the addition operator to the previously created symbols, <code>a</code> and <code>b</code>. </li>
<li><code>d</code> is created by adding two literal values. </li>
</ul>
<p>Numbers, such as the integers <code>3</code> and <code>4</code> are called <em>literals</em>, rather than <em>symbols</em>.</p>
<h2 id="how-to-define-a-symbol">How to define a symbol</h2>
<p><strong>Numeric and string symbols</strong> are defined in GAUSS using the equals sign as we saw previously. Here are some more examples:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Define the symbol 'e' to be a 3x1 vector
e = { 2.1, 0.9, 3.8 };

// Define the symbol 'f' to be the
// largest element of the vector 'e'
f = maxc(e);

// Define the symbol 'g' to be a 10x2 random normal matrix
g = rndn(10,2);

// Define the symbol 'h' to be a string
h = "String symbols contain text";</code></pre>
<p><strong>Procedure (<code>proc</code>) and function (<code>fn</code>) names</strong> are also symbols. Below are some simple examples of procedure definitions:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">/*
** The procedure and function definitions below define the symbols
** 'doubleIt' and 'squareIt'.
*/

proc (1) = doubleIt(X);
    retp(X .* 2);
endp;

fn squareIt(X) = X .^ 2;</code></pre>
<div class="alert alert-info" role="alert">Read more about <a href="https://www.aptech.com/blog/basics-of-gauss-procedures/" target="_blank" rel="noopener">creating GAUSS procedures</a> in this blog post.</div>
<h2 id="basic-undefined-symbol-examples">Basic undefined symbol examples</h2>
<p>Any time a symbol is referenced on the right side of an equation before it has been defined can cause <code>Error G00025: Undefined symbol</code>. Here are a few simple examples:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Clear out all symbols in the GAUSS workspace
new;

// Since 'a' has not been defined,
// this line will cause an error
b = a;</code></pre>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Clear out all symbols in the GAUSS workspace
new;

b = 3;

// Since 'a' has not been defined,
// this line will cause an error
c = a + b;</code></pre>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Clear out all symbols in the GAUSS workspace
new;

a = { 2, 4, 6 };

// Since the procedure 'foo' has not been defined,
// this line will cause an error
X = foo(a);</code></pre>
<h2 id="solve-a-simple-undefined-symbols-error">Solve a simple undefined symbols error</h2>
<p>If we run a file named <code>estimate.gss</code> with the following contents:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Clear all symbols from the GAUSS workspace
new;

/*
** Simulate random normal variables
*/
X = rndn(nobs, nvars);

/*
** Simulate a random normal response variable
*/
y = rndn(nobs, 1);

/*
** Estimate a linear model
*/
call glm(y, X, "normal");</code></pre>
<p>we will get the following error messages:</p>
<pre>G0025 : Undefined symbol: 'nobs'  [estimate.gss, line 6]
G0025 : Undefined symbol: 'nvars' [estimate.gss, line 6]</pre>
<p>These error messages tell us that line 6 of our code is using two symbols that have not yet been defined, <code>nobs</code> and <code>nvars</code>. To resolve these errors, we need to set those symbols to appropriate values.</p>
<p>The inputs to the <a href="https://docs.aptech.com/gauss/rndn.html" target="_blank" rel="noopener"><code>rndn</code></a> function need to be scalar values that represent the number of rows and columns of the output matrix. We set them to 100 and 4 respectively in the code below to resolve the errors.</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Clear all symbols from the GAUSS workspace
new;

// Specify the number of observations to simulate
nobs = 100;

// Specify the number of columns to simulate
nvars = 4;

/*
** Simulate random normal variables
*/
X = rndn(nobs, nvars);

/*
** Simulate a random normal response variable
*/
y = rndn(nobs, 1);

/*
** Estimate a linear model
*/
call glm(y, X, "normal");</code></pre>
<p>After these changes the code will run successfully.</p>
<h2 id="what-causes-undefined-proc-or-function-symbols">What causes undefined proc or function symbols?</h2>
<p>Now let's move to a less obvious example. Let's suppose we have a file <code>arimafit-example.gss</code> with these contents:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Clear all symbols from GAUSS workspace
new;

// Create file name with full path
fname = getGAUSSHome() $+ "pkgs/tsmt/examples/enders_sim2.dat";

p = 3;
d = 1;
q = 1;

// Run arima estimation
call arimaFit(fname, "ar2", p, d, q);</code></pre>
<p>When we run this file, we get the error:</p>
<pre>G0025 : Undefined symbol: 'arimaFit' [arimafit-example.gss, line 12]</pre>
<p>In this example, we can tell that <code>arimaFit</code> is a GAUSS procedure or function. There are four main reasons why a procedure or function might be undefined in your GAUSS code:</p>
<h3 id="1-it-was-added-in-a-newer-version-of-gauss-than-you-have">1. It was added in a newer version of GAUSS than you have.</h3>
<p>You can search the <a href="https://docs.aptech.com/gauss/changelog.html" target="_blank" rel="noopener">GAUSS Change Log</a> for the procedure or function to see if it has been added in a newer version.</p>
<h3 id="2-it-is-in-a-library-that-you-do-not-have-loaded">2. It is in a library that you do not have loaded.</h3>
<p><a href="https://docs.aptech.com/gauss/tsmt/arimafit.html" target="_blank" rel="noopener"><code>arimaFit</code></a> from our above code snippet is from the <a href="https://docs.aptech.com/gauss/tsmt/index.html" target="_blank" rel="noopener">GAUSS Time Series MT</a> add-on package. If this is the case, you will need to <a href="https://www.aptech.com/blog/using-gauss-packages-complete-guide/" target="_blank" rel="noopener">make sure that the package is installed and loaded</a> correctly.</p>
<p>Undefined references to the procedures <code>maxset</code>, <code>optset</code>, <code>maxlik</code> and <code>optmum</code> are sometimes found undefined in publicly available third-party code.</p>
<h3 id="3-it-is-in-a-code-file-that-gauss-has-not-been-told-about">3. It is in a code file that GAUSS has not been told about.</h3>
<p><a href="https://www.aptech.com/blog/basics-of-gauss-procedures/#define_procs" target="_blank" rel="noopener">Our Basics of GAUSS Procedures blog</a> explains the four ways to tell GAUSS about your user-defined procedure. </p>
<div class="alert alert-info" role="alert">The symbol named could also be misspelled, but the <a href="https://www.aptech.com/blog/controlling-the-gauss-autocomplete-behavior/" target="_blank" rel="noopener">GAUSS autocomplete</a> should help prevent that.</div>
<h3 id="4-running-the-code-line-by-line">4. Running the code line-by-line</h3>
<p>When you run a file all at once, GAUSS allows you to place procedures wherever you like, such as the end of the file.</p>
<pre class="hljs-container hljs-container-solo"><code>new;

a = 3;

b = doubleIt(a);

proc (1) = doubleIt(x);
    retp(2 * x);
endp;</code></pre>
<p>However, if you run a program file like the one above, line-by-line, you will get an undefined symbol error. If you run the entire file at once, GAUSS will search the file for any procedures that it does not know about. However, when you run the code line-by-line, GAUSS only runs the code you tell it to run.</p>
<p>You can resolve this problem, by either:</p>
<ol>
<li>Running the code under the debugger.</li>
<li>Adding the procedures to a GAUSS library or <a href="https://www.aptech.com/blog/basics-of-gauss-procedures/#dot_g_proc_file" target="_blank" rel="noopener">a <code>.g</code> file</a>.</li>
<li>Highlighting all lines of the needed procedures and running them first.</li>
</ol>
<h2 id="conclusion">Conclusion</h2>
<p>Congratulations! In today's blog, you have learned that:</p>
<ul>
<li>GAUSS symbols are labels, or names, that represent data, procedures and functions.</li>
<li>Use of a symbol on the right side of an equation before it is defined, or assigned a value, can cause an undefined symbol error.</li>
<li>Symbols are commonly defined by using the equals operator as well as loading libraries.</li>
</ul>
<h3 id="further-reading">Further Reading</h3>
<ol>
<li><a href="https://www.aptech.com/blog/understanding-errors-g0064-operand-missing/" target="_blank" rel="noopener">Understanding Errors: G0064 Operand Missing</a></li>
<li><a href="https://www.aptech.com/blog/understanding-errors-g0058-index-out-of-range/" target="_blank" rel="noopener">Understanding Errors: G0058 Index out-of-Range</a></li>
<li><a href="https://www.aptech.com/blog/make-your-code-portable-data-paths/" target="_blank" rel="noopener">Make your code portable: Data paths</a></li>
<li><a href="https://www.aptech.com/blog/the-current-working-directory-what-you-need-to-know/" target="_blank" rel="noopener">The Current Working Directory: What you need to know</a></li>
</ol>]]></content:encoded>
					
					<wfw:commentRss>https://www.aptech.com/blog/understanding-errors-g0025-undefined-symbol/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
