<?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: Count Variable inside Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308898#M66358</link>
    <description>&lt;P&gt;Since the Macro language is primarily a text generator you need to tell when you are doing calculations. You also need to use &amp;amp;L1 to refer to the assigned value of the macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;%let L2= %eval ( &amp;amp;L1+7);&lt;/P&gt;
&lt;P&gt;and similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that %eval only does integer arithmetic. You&amp;nbsp;will need %sysevalf to do decimals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excessive calculations in the macro language is not a good idea...&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2016 21:46:47 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-11-02T21:46:47Z</dc:date>
    <item>
      <title>Count Variable inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308893#M66355</link>
      <description>&lt;P&gt;Hi, I'm trying this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro month(L1);&lt;BR /&gt;%let L1=&amp;amp;L1;&lt;BR /&gt;%let L2=L1+7;&lt;BR /&gt;%let L3=L2+7;&lt;BR /&gt;%let L4=L3+7;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data L1;&lt;BR /&gt;set interval.d_&amp;amp;L2;&lt;BR /&gt;keep _LABEL_ d_&amp;amp;L2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%month(20499);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The proble is that L2=20499+7; and its a error because the dataset interval.d_20499+7 does not exist. I need that L2=20506&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas??&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 21:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308893#M66355</guid>
      <dc:creator>mariange8282</dc:creator>
      <dc:date>2016-11-02T21:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count Variable inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308898#M66358</link>
      <description>&lt;P&gt;Since the Macro language is primarily a text generator you need to tell when you are doing calculations. You also need to use &amp;amp;L1 to refer to the assigned value of the macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;%let L2= %eval ( &amp;amp;L1+7);&lt;/P&gt;
&lt;P&gt;and similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that %eval only does integer arithmetic. You&amp;nbsp;will need %sysevalf to do decimals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excessive calculations in the macro language is not a good idea...&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 21:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308898#M66358</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-02T21:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count Variable inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308958#M66389</link>
      <description>&lt;P&gt;The question is, do you understand the difference between macro and datastep? &amp;nbsp;Datastep is the SAS language, it is designed to have fiull functionality, all data structures, operations and such like need to manipulate data. &amp;nbsp;Macro on the other hand has none of this. &amp;nbsp;It is purely there to generate some text which would resolve to be datastep. &amp;nbsp;It has no data structures other than text, and no functionality within itself to process data. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next question would be, why is the data all split up, with data actually appearing as dataset name. &amp;nbsp;Thats an innefficient methodology from a programming perspective. &amp;nbsp;Far simpler to do:&lt;/P&gt;
&lt;PRE&gt;data all_data;
  format dte date9.;
  set interval.d: indsname=nme;
  dte=input(nme,best.);   /* set whatever the format of 20499 is? */
run;&lt;/PRE&gt;
&lt;P&gt;Not sure what the 20499 stands for in your example, maybe its a numeric date, then best should do it. You then have one dataset with a variable to indicate date timestamp. &amp;nbsp;Then you can use datasteps, interval functions etc.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 09:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Variable-inside-Macro/m-p/308958#M66389</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-03T09:32:34Z</dc:date>
    </item>
  </channel>
</rss>

