<?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: Macro create aggregate file at the first itteration of a group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178102#M34071</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for not making it clear.&lt;/P&gt;&lt;P&gt;I'll get back to this issue later.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Apr 2014 15:00:38 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2014-04-15T15:00:38Z</dc:date>
    <item>
      <title>Macro create aggregate file at the first itteration of a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178100#M34069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;My data is like that:&lt;/P&gt;&lt;P&gt;period&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; day&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var2...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each period has many days and I make day index variable (1 to n for the whole dataset)&lt;/P&gt;&lt;P&gt;I make a macro to analyze data for each Day and combine daily result into a Period_file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since there is no rule for when is the first day of the period, I don't know how to tell SAS that, create a new Peirod_file when start new group of iteration.&lt;/P&gt;&lt;P&gt;It should be something like that&lt;/P&gt;&lt;P&gt;Data Summary_&amp;amp;period;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (START of new start/end group) %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set daily;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Summary_&amp;amp;period&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; daily;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The whole sample code is like that: &lt;/P&gt;&lt;P&gt;%macro test (start,end,period);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=&amp;amp;start %to &amp;amp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data Temp_&amp;amp;i;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set mydata;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if day= &amp;amp;i;&amp;nbsp; run;&lt;BR /&gt; *ANALYSIS SECTION FOR EACH Period FILE; there will be 01 summary file per period;&lt;BR /&gt; Proc means noprint;&lt;BR /&gt; var&amp;nbsp; var1;&lt;BR /&gt; output out=daily&lt;BR /&gt; N=N;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Summary_&amp;amp;period;&lt;/P&gt;&lt;P&gt;if (START of new start/end group) %then %do;&lt;BR /&gt;set daily;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;set Summary_&amp;amp;period daily;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt;%mend test;&lt;BR /&gt;&lt;STRONG&gt;%test (1,50,1);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;%test (51,65,2);&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2014 01:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178100#M34069</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-04-13T01:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro create aggregate file at the first itteration of a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178101#M34070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hard to follow your requirement.&lt;/P&gt;&lt;P&gt;Please attach some sample input and desired output data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 07:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178101#M34070</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-04-14T07:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro create aggregate file at the first itteration of a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178102#M34071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for not making it clear.&lt;/P&gt;&lt;P&gt;I'll get back to this issue later.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2014 15:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-create-aggregate-file-at-the-first-itteration-of-a-group/m-p/178102#M34071</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-04-15T15:00:38Z</dc:date>
    </item>
  </channel>
</rss>

