<?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: How to loop data values into a diffreent macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453887#M114734</link>
    <description>&lt;P&gt;While it might be possible to combine the two DATA steps, let's work with them as they are now.&amp;nbsp; First, remove the two CALL SYMPUT statements.&amp;nbsp; Then add in their place:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call execute (cats(%nrstr('%visit'), '(', month, ',' , year, ')'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Apr 2018 12:35:14 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-04-13T12:35:14Z</dc:date>
    <item>
      <title>How to loop data values into a diffreent macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453860#M114729</link>
      <description>&lt;P&gt;The below output datasets, I would like to create&amp;nbsp;do loop (month and year) , so that it will iterate total no of times . Can you please someone help me?&lt;/P&gt;&lt;P&gt;so that these values I can pass into a different macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;date_&lt;/TD&gt;&lt;TD&gt;month&lt;/TD&gt;&lt;TD&gt;year&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/3/2018&lt;/TD&gt;&lt;TD&gt;3/3/2018&lt;/TD&gt;&lt;TD&gt;303&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/10/2018&lt;/TD&gt;&lt;TD&gt;3/10/2018&lt;/TD&gt;&lt;TD&gt;310&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/17/2018&lt;/TD&gt;&lt;TD&gt;3/17/2018&lt;/TD&gt;&lt;TD&gt;317&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/24/2018&lt;/TD&gt;&lt;TD&gt;3/24/2018&lt;/TD&gt;&lt;TD&gt;324&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/31/2018&lt;/TD&gt;&lt;TD&gt;3/31/2018&lt;/TD&gt;&lt;TD&gt;331&lt;/TD&gt;&lt;TD&gt;2018&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp;sub_table_date='01MAR2018'd;&lt;BR /&gt;&amp;nbsp;end_date=intnx('month', sub_table_date, 0, 'e');&lt;BR /&gt;&amp;nbsp;do date=sub_table_date to end_date;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;if weekday(date)=7 then output ;&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;format date mmddyy10.;&lt;BR /&gt;&amp;nbsp;keep date;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;data test;&lt;BR /&gt;&amp;nbsp; set want;&lt;BR /&gt;&amp;nbsp;date_= put(date, mmddyy10.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;month=trim(compress(substr(date_,1,5),'/'));&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;year= substr(date_,7,4);&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;call symput( 'mon',month);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;call symput( 'yr',year);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally I would like pass this 'mon' and 'yr'&amp;nbsp;value into a do loop statement.&lt;/P&gt;&lt;P&gt;%visit(&amp;amp;mon.,&amp;amp;yr.);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 09:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453860#M114729</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-04-13T09:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop data values into a diffreent macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453871#M114732</link>
      <description>&lt;P&gt;Why?&amp;nbsp; This should actually be the first question you always ask yourself when you state use macro.&amp;nbsp; Base SAS can do anything you need with simpler, easier to maintain code.&amp;nbsp; Macro is just a find replace system.&amp;nbsp; There are methods to do what you ask, call execute for instance, but present your problem - show some test data in the form of a datastep and what the required output would be.&amp;nbsp; Its quite likely as simple addition of a by group would remove this need totally.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 10:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453871#M114732</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-13T10:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop data values into a diffreent macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453887#M114734</link>
      <description>&lt;P&gt;While it might be possible to combine the two DATA steps, let's work with them as they are now.&amp;nbsp; First, remove the two CALL SYMPUT statements.&amp;nbsp; Then add in their place:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call execute (cats(%nrstr('%visit'), '(', month, ',' , year, ')'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 12:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453887#M114734</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-13T12:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop data values into a diffreent macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453906#M114741</link>
      <description>&lt;P&gt;Why not in a single data step? Your converting date values to character and passing them as parameters for a macro. I suggest using&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;approach with in do loop like:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let date=01MAR2018;
Data _NULL_;
do i="&amp;amp;date"D to intnx('month', "&amp;amp;date"D, 0, 'e');
if weekday(i)=7 then call execute (cats(%nrstr('%visit'), '(', put(i,mmddyy4.), ',' , put(year(i),NLDATEYR4.), ')'));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/453906#M114741</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-13T13:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop data values into a diffreent macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/454106#M114779</link>
      <description>Thank you for giving me a good sugesstion. I implemented it's good pratice.&lt;BR /&gt;One more clarification in that step can I execute proc append. If so then first i need to create a seperate proc append macro and pass into this same call execute step. Is that make sense?</description>
      <pubDate>Sat, 14 Apr 2018 02:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-data-values-into-a-diffreent-macro/m-p/454106#M114779</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-04-14T02:32:34Z</dc:date>
    </item>
  </channel>
</rss>

