<?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: Can you help me &amp;quot;Macro-tize&amp;quot; my code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165726#M31965</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RW9,&lt;/P&gt;&lt;P&gt;that's exactly what i was looking for. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Thank you for going above and beyond and showing me a few approaches to solve this. much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Apr 2014 13:41:37 GMT</pubDate>
    <dc:creator>SAShole</dc:creator>
    <dc:date>2014-04-03T13:41:37Z</dc:date>
    <item>
      <title>Can you help me "Macro-tize" my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165722#M31961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some code I've written using data-step but after many hours of troubleshooting i can't get it to work in Macro language. can you 'convert' it for me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Get_DataSets(date,date2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;date.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;date2.;&lt;/P&gt;&lt;P&gt;%mend Get_DataSets;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dates;&lt;/P&gt;&lt;P&gt;length date2 $8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; date=intnx('month','01MAY2013'd,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; year=put(year(date),$4.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; month=put(month(date),z2.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; date2=compress(year||"_"||month);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %Get_DataSets(date,date2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date monyy.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep date date2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i&amp;nbsp; wanna call a macro within a macro but I can't figure out how to send my two macro variables to %Get_DataSets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Apr 2014 21:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165722#M31961</guid>
      <dc:creator>SAShole</dc:creator>
      <dc:date>2014-04-02T21:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me "Macro-tize" my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165723#M31962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look up call execute to replace your %get_data in the middle of your data step.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Apr 2014 21:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165723#M31962</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-02T21:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me "Macro-tize" my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165724#M31963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are not calling a macro within a macro, you are attempting perhaps to call a macro inside a data step, but that normally cannot work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like what you want is to generate calls to a macro based on values in a data set.&lt;/P&gt;&lt;P&gt;You can use the new CAT type functions to generate the macro call.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; cmd = cats('%nrstr(%get_data)(',date,',',date2,')') ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;To execute the generated macro calls you can use CALL EXECUTE.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(cmd);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Or you can just use PUT statements to write out the macro calls and then %INC the generated code.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;filename code temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;file code ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;put '%get_data(' date ',' date2 ')' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%inc code / source2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or perhaps you just want to understand how to loop by month in a macro %DO loop?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro outer(start);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %local i date year month date2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %do i=1 to 9 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let date = %sysfunc(intnx(month,&amp;amp;start,&amp;amp;i)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let year = %sysfunc(year(&amp;amp;date),4.)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let month = %sysfunc(month(&amp;amp;date),z2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %get_datasets(&amp;amp;date,&amp;amp;year._&amp;amp;month);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend outer;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%outer('01MAY2013'd)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Apr 2014 22:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165724#M31963</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-04-02T22:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me "Macro-tize" my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165725#M31964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what you are trying to achieve however the below produces the list of put statements.:&lt;/P&gt;&lt;P&gt;%macro Get_DataSets(date,date2);&lt;BR /&gt;&amp;nbsp; %put &amp;amp;date.;&lt;BR /&gt;&amp;nbsp; %put &amp;amp;date2.;&lt;BR /&gt;%mend Get_DataSets;&lt;/P&gt;&lt;P&gt;data dates;&lt;BR /&gt;&amp;nbsp; length date 8. date2 $8.;&lt;BR /&gt;&amp;nbsp; do i=1 to 9;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=intnx('month','01MAY2013'd,i);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date2=put(year(date),4.)||"_"||put(month(date),z2.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%Get_DataSets('||put(date,mmyy.)||','||strip(date2)||');');&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2014 09:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165725#M31964</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-04-03T09:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me "Macro-tize" my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165726#M31965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RW9,&lt;/P&gt;&lt;P&gt;that's exactly what i was looking for. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Thank you for going above and beyond and showing me a few approaches to solve this. much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2014 13:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-help-me-quot-Macro-tize-quot-my-code/m-p/165726#M31965</guid>
      <dc:creator>SAShole</dc:creator>
      <dc:date>2014-04-03T13:41:37Z</dc:date>
    </item>
  </channel>
</rss>

