<?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: Global variables program error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877088#M346489</link>
    <description>&lt;P&gt;When you execute a PROC statement without a DATA= option, SAS tries to use the&amp;nbsp;&lt;EM&gt;last created&lt;/EM&gt;&amp;nbsp;dataset; if you did not create a dataset in your SAS session, the system optiion _LAST_ is _NULL_, and you'll get this ERROR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The examples are there to show &lt;EM&gt;how the macro processor creates code&lt;/EM&gt;; actual function of the created code is not necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 14:52:41 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-05-23T14:52:41Z</dc:date>
    <item>
      <title>Global variables program error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877082#M346487</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;I am trying the code execute the code given in&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1lhhti7fjxgb1n1fuiubqk11h4d.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1lhhti7fjxgb1n1fuiubqk11h4d.htm&lt;/A&gt;&lt;/FONT&gt;&lt;BR /&gt;But, It's not working.&lt;/P&gt;&lt;P&gt;Please, help me to understand why this error is coming and how to rectify it.&lt;/P&gt;&lt;P&gt;These programs given at the above SAS site say that it will give some output but instead of that I am getting errors.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;Code is:&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%macro vars(first=1,last=);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%global gfirst glast;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%let gfirst=&amp;amp;first;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%let glast=&amp;amp;last;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;var test&amp;amp;first-test&amp;amp;last;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%mend vars;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;proc print;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%vars(last=50)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;title "Analysis of Tests &amp;amp;gfirst-&amp;amp;glast";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;In the log:&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;26 options mprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;27 %macro vars(first=1,last=);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;28 %global gfirst glast;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;29 %let gfirst=&amp;amp;first;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;30 %let glast=&amp;amp;last;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;31 var test&amp;amp;first-test&amp;amp;last;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;32 %mend vars;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;33 proc print;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR: There is not a default input data set (_LAST_ is _NULL_).&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;34 %vars(last=50)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;MPRINT(VARS): var test1-test50;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;35 title "Analysis of Tests &amp;amp;gfirst-&amp;amp;glast";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;36 run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;real time 0.01 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;cpu time 0.01 seconds&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Similarly, the program given in&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0i4icf2nv7wu7n1lm4wf1epykfh.htm#p06942xl3jrvwpn1vt2rmuza3vwi" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0i4icf2nv7wu7n1lm4wf1epykfh.htm#p06942xl3jrvwpn1vt2rmuza3vwi&lt;/A&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;is also not working.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;The code from this link is:&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%macro namels3(name,number);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%local n;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%global g_number;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%let g_number=&amp;amp;number;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%do n=1 %to &amp;amp;number;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&amp;amp;name&amp;amp;n&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%mend namels3;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%let n=North State Industries;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;proc print;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;var %namels3(dept,5);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;title "Quarterly Report for &amp;amp;n";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;footnote "Survey of &amp;amp;g_number Departments";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;In the log:&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;37 %macro namels3(name,number);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;38 %local n;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;39 %global g_number;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;40 %let g_number=&amp;amp;number;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;41 %do n=1 %to &amp;amp;number;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;42 &amp;amp;name&amp;amp;n&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;43 %end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;44 %mend namels3;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;45 %let n=North State Industries;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;46&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;47 proc print;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR: There is not a default input data set (_LAST_ is _NULL_).&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;48 var %namels3(dept,5);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;MPRINT(NAMELS3): dept1 dept2 dept3 dept4 dept5&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;49 title "Quarterly Report for &amp;amp;n";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;50 footnote "Survey of &amp;amp;g_number Departments";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;51 run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;real time 0.00 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;cpu time 0.00 seconds&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 14:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877082#M346487</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-23T14:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables program error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877085#M346488</link>
      <description>&lt;P&gt;This error has nothing to do with GLOBAL macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have to tell PROC PRINT what data set to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=somedatasetname;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't use the DATA= option, PROC PRINT tries to use the last data set created, but that doesn't apply here, there is no "last data set created" in this SAS session, there have been no data sets created in this session (that's what the error message is saying).&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 14:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877085#M346488</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-23T14:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables program error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877088#M346489</link>
      <description>&lt;P&gt;When you execute a PROC statement without a DATA= option, SAS tries to use the&amp;nbsp;&lt;EM&gt;last created&lt;/EM&gt;&amp;nbsp;dataset; if you did not create a dataset in your SAS session, the system optiion _LAST_ is _NULL_, and you'll get this ERROR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The examples are there to show &lt;EM&gt;how the macro processor creates code&lt;/EM&gt;; actual function of the created code is not necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 14:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877088#M346489</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-23T14:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables program error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877096#M346493</link>
      <description>Thank you very much for providing the clarification.</description>
      <pubDate>Tue, 23 May 2023 15:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877096#M346493</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-23T15:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables program error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877097#M346494</link>
      <description>&lt;P&gt;Thank you very much for such a clear clarification.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 15:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Global-variables-program-error/m-p/877097#M346494</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-23T15:24:42Z</dc:date>
    </item>
  </channel>
</rss>

