<?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: sas macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/485230#M287106</link>
    <description>&lt;P&gt;When you use syntax like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then Proc Print, or other Procedure, &amp;nbsp;will assume that you want to use the last created data set as input.&lt;/P&gt;
&lt;P&gt;If your current session has not created any data set then you get that error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While SAS is helpful about making guesses for things like the last data set it is very poor practice to rely on those guesses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also suggest passing a "stem" value for the variable list to make the macro a little more useful&lt;/P&gt;
&lt;PRE&gt;%macro vars(stem=test,first=1,last=);
   %global gfirst glast;
   %let gfirst=&amp;amp;first;
   %let glast=&amp;amp;last;
   var &amp;amp;stem.&amp;amp;first-&amp;amp;stem.&amp;amp;last;
%mend vars;&lt;/PRE&gt;
&lt;P&gt;Then you could create a list of any varaibles that start with a common name portion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the data set you attempt to print or process&amp;nbsp;has to have those variables in it and really should be named.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Aug 2018 17:45:56 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-08-08T17:45:56Z</dc:date>
    <item>
      <title>sas macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484967#M287101</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro vars(first=1,last=);
   %global gfirst glast;
   %let gfirst=&amp;amp;first;
   %let glast=&amp;amp;last;
   var test&amp;amp;first-test&amp;amp;last;
%mend vars;
%put &amp;amp;gfirst;
proc print;
   %vars(last=50)
   title "Analysis of Tests &amp;amp;gfirst-&amp;amp;glast";
run;
PROC PRINT;
   VAR TEST1-TEST50;
   TITLE "Analysis of Tests 1-50";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22313iACF7E305A351387F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 02:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484967#M287101</guid>
      <dc:creator>vinod4842</dc:creator>
      <dc:date>2018-08-08T02:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: sas macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484969#M287102</link>
      <description>&lt;P&gt;Please post the log using {i}.&lt;/P&gt;
&lt;P&gt;MS office documents are best avoided.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 02:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484969#M287102</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-08T02:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: sas macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484971#M287103</link>
      <description>&lt;P&gt;thank you again edited&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 02:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484971#M287103</guid>
      <dc:creator>vinod4842</dc:creator>
      <dc:date>2018-08-08T02:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: sas macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484973#M287104</link>
      <description>&lt;P&gt;The error messages seems pretty clear.&lt;/P&gt;
&lt;P&gt;You need to tell SAS what dataset you want it to print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It has nothing to do with the macro.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 02:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484973#M287104</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-08T02:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: sas macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484974#M287105</link>
      <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; said, add &lt;FONT face="courier new,courier"&gt;data=&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Also, your macro would probably be more&amp;nbsp;useful like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro vars(first=1,last=);
   var test&amp;amp;first - test&amp;amp;last;
   title "Analysis of Tests &amp;amp;first-&amp;amp;last";
%mend vars;

proc print;
   %vars(last=50)
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 03:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/484974#M287105</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-08-08T03:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: sas macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/485230#M287106</link>
      <description>&lt;P&gt;When you use syntax like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then Proc Print, or other Procedure, &amp;nbsp;will assume that you want to use the last created data set as input.&lt;/P&gt;
&lt;P&gt;If your current session has not created any data set then you get that error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While SAS is helpful about making guesses for things like the last data set it is very poor practice to rely on those guesses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also suggest passing a "stem" value for the variable list to make the macro a little more useful&lt;/P&gt;
&lt;PRE&gt;%macro vars(stem=test,first=1,last=);
   %global gfirst glast;
   %let gfirst=&amp;amp;first;
   %let glast=&amp;amp;last;
   var &amp;amp;stem.&amp;amp;first-&amp;amp;stem.&amp;amp;last;
%mend vars;&lt;/PRE&gt;
&lt;P&gt;Then you could create a list of any varaibles that start with a common name portion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the data set you attempt to print or process&amp;nbsp;has to have those variables in it and really should be named.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 17:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macros/m-p/485230#M287106</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-08T17:45:56Z</dc:date>
    </item>
  </channel>
</rss>

