<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Variable is not defined or does not exist. GetVarc Help_Needed in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530067#M5646</link>
    <description>&lt;P&gt;It seems to be having trouble reading in any observations from the table even with the 1 hardcoded in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: No observations have been read from data set WORK.TESTCOUNT.&lt;/P&gt;&lt;P&gt;Arguments passed to GETVARC:&lt;BR /&gt;1 dsid = 3&lt;BR /&gt;2 (Numeric Literal) = 1&lt;BR /&gt;Program returning prematurely at line 130&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jan 2019 14:08:43 GMT</pubDate>
    <dc:creator>mdlucas1</dc:creator>
    <dc:date>2019-01-25T14:08:43Z</dc:date>
    <item>
      <title>Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/529860#M5611</link>
      <description>&lt;P&gt;I am new to SAS and I am currently trying to write a program that uses Proc SQL; to create a table. After the table is created, I am trying to call variable/fields from that table in SCL to use later. Below is the section of code that is getting the error (names of tables and variables have been changed), and the error itself. Any advice on what I'm doing wrong would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SUBMIT continue; 

proc sql; 
create table work.TestCount 
as select * , count(*) as field3 
from sasTest.table1 
where field1 ne ""; 
quit; 

endsubmit; 

refTest='work.TestCount'; 
FieldTest=open(refTest,'u'); 

TestField1=getvarc(FieldTest,varnum(FieldTest,field1)); &amp;lt;-- ERROR IS STOPPING PROGRAM HERE 
TestField2=getvarc(FieldTest,varnum(FieldTest,field2)); 
TestField3=getvarn(FieldTest,varnum(FieldTest,field3));&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*** Line 130: [ERROR: #70] Calling function GETVARC. ERROR: Variable is not defined or does not exist.&lt;BR /&gt;Arguments passed to GETVARC:&lt;BR /&gt;1 FieldTest = 3&lt;BR /&gt;2 (Numeric Expression $T0) = 0&lt;BR /&gt;Program returning prematurely at line 130&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 20:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/529860#M5611</guid>
      <dc:creator>mdlucas1</dc:creator>
      <dc:date>2019-01-24T20:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/529889#M5613</link>
      <description>&lt;P&gt;This is a very interesting question. Please try replacing this fragment&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;refTest='work.TestCount'; 
FieldTest=open(refTest,'u'); 

TestField1=getvarc(FieldTest,varnum(FieldTest,field1));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;with this one:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dsid = open( "work.TestCount", "i" );

position = varnum( dsid, field1 );

TestField1 = getvarc( dsid, position );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;U&gt;References&lt;/U&gt;&lt;/P&gt;&lt;P&gt;[1] &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148395.htm" target="_self"&gt;Varnum() function&lt;/A&gt;&lt;/P&gt;&lt;P&gt;[2] &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000148395.htm" target="_self"&gt;Open() function&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 21:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/529889#M5613</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2019-01-24T21:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530043#M5641</link>
      <description>&lt;P&gt;Thanks for replying. This is unfortunately giving a similar error on the Getvarc again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a copy of the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*** Line 130: [ERROR: #70] Calling function GETVARC. ERROR: Variable is not defined or does not exist.&lt;BR /&gt;Arguments passed to GETVARC:&lt;BR /&gt;1 dsid = 3&lt;BR /&gt;2 TestField1 = 0&lt;BR /&gt;Program returning prematurely at line 130&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 13:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530043#M5641</guid>
      <dc:creator>mdlucas1</dc:creator>
      <dc:date>2019-01-25T13:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530064#M5644</link>
      <description>&lt;P&gt;What happens if you type&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TestField1 = getvarc( dsid, 1 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 13:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530064#M5644</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2019-01-25T13:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530067#M5646</link>
      <description>&lt;P&gt;It seems to be having trouble reading in any observations from the table even with the 1 hardcoded in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: No observations have been read from data set WORK.TESTCOUNT.&lt;/P&gt;&lt;P&gt;Arguments passed to GETVARC:&lt;BR /&gt;1 dsid = 3&lt;BR /&gt;2 (Numeric Literal) = 1&lt;BR /&gt;Program returning prematurely at line 130&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 14:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530067#M5646</guid>
      <dc:creator>mdlucas1</dc:creator>
      <dc:date>2019-01-25T14:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530082#M5650</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39130"&gt;@gregl_sas&lt;/a&gt;&amp;nbsp;helped me nicely with my SCL question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Using-SCL-to-prevent-entries-already-in-dset-through-PROC-FSEDIT/m-p/499945#M251" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/New-SAS-User/Using-SCL-to-prevent-entries-already-in-dset-through-PROC-FSEDIT/m-p/499945#M251&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe this person can have a look at this question, too.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 15:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530082#M5650</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2019-01-25T15:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530091#M5652</link>
      <description>&lt;P&gt;Thanks for the attempts, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235176"&gt;@pink_poodle&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 15:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530091#M5652</guid>
      <dc:creator>mdlucas1</dc:creator>
      <dc:date>2019-01-25T15:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530105#M5654</link>
      <description>&lt;P&gt;There are a couple things happening with the GETVARC function in your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 - The way you have the GETVARC function defined:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TestField1=getvarc(FieldTest,varnum(FieldTest,field1));&lt;/P&gt;
&lt;P&gt;This code is expecting the FIELD1 variable in the VARNUM function to be a character value.&amp;nbsp; The way that you have this coded, FIELD1 is a variable that would need to contain the character value 'field1'.&amp;nbsp; So, your GETVARC statements should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TestField1=getvarc(FieldTest,varnum(FieldTest,'field1'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 - Just making the above change is not enough to make the code work though (you will get a different error message).&amp;nbsp; With the GETVARC/N functions, you need to make an observation from the table available.&amp;nbsp; This is done with the FETCH or FETCHOBS function.&amp;nbsp; So, the code after your SUBMIT block would need to look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;endsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;refTest='work.TestCount'; &lt;BR /&gt;FieldTest=open(refTest,'u');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rc=fetch(FieldTest);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TestField1=getvarc(FieldTest,varnum(FieldTest,'field1'));/* &amp;lt;-- ERROR IS STOPPING PROGRAM HERE */&lt;BR /&gt;TestField2=getvarc(FieldTest,varnum(FieldTest,'field2')); &lt;BR /&gt;TestField3=getvarn(FieldTest,varnum(FieldTest,'field3'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you have any problems or questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Greg&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 16:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530105#M5654</guid>
      <dc:creator>gregl_sas</dc:creator>
      <dc:date>2019-01-25T16:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is not defined or does not exist. GetVarc Help_Needed</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530118#M5663</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked perfectly. Thanks so much!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 16:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Variable-is-not-defined-or-does-not-exist-GetVarc-Help-Needed/m-p/530118#M5663</guid>
      <dc:creator>mdlucas1</dc:creator>
      <dc:date>2019-01-25T16:55:42Z</dc:date>
    </item>
  </channel>
</rss>

