<?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: identify begin of month to current date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81945#M23589</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A minor modification on my previous code will do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards truncover;&lt;/P&gt;&lt;P&gt;input var:$ date :mmddyy10. flag;&lt;/P&gt;&lt;P&gt;format date mmddyy10.;&lt;/P&gt;&lt;P&gt;_id=cats(var,year(date),week(date));&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;ann 3/6/2012&lt;/P&gt;&lt;P&gt;ann 3/7/2012&lt;/P&gt;&lt;P&gt;ann 3/8/2012&lt;/P&gt;&lt;P&gt;ann 3/9/2012 1&lt;/P&gt;&lt;P&gt;joe 4/9/2012&lt;/P&gt;&lt;P&gt;joe 4/10/2012&lt;/P&gt;&lt;P&gt;joe 4/11/2012&lt;/P&gt;&lt;P&gt;joe 4/12/2012&lt;/P&gt;&lt;P&gt;joe 4/13/2012&lt;/P&gt;&lt;P&gt;joe 4/16/2012&lt;/P&gt;&lt;P&gt;joe 4/17/2012&lt;/P&gt;&lt;P&gt;joe 4/18/2012&lt;/P&gt;&lt;P&gt;joe 4/19/2012&lt;/P&gt;&lt;P&gt;joe 4/20/2012&lt;/P&gt;&lt;P&gt;joe 5/1/2012&lt;/P&gt;&lt;P&gt;joe 5/2/2012 1&lt;/P&gt;&lt;P&gt;joe 5/3/2012&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 by 1 until (last._id);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;by _id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if flag=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; add_flag=1;&lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 by 1 until (last._id);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;by _id;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if flag=1 then &lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Apr 2012 19:03:57 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-04-12T19:03:57Z</dc:date>
    <item>
      <title>identify begin of month to current date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81944#M23588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone for all your help. I have another query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following data var date and flag. THere is a flag on certain dates for certain var in a month.&lt;/P&gt;&lt;P&gt;I want to create a column called agg flag which puts a 1 in all dates before and including the date that has the flag from the beginning of the month to the date which has a flag, grouped by var&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="WIDTH: 237px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="41" width="77"&gt;var&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none;" width="75"&gt;date&lt;/TD&gt;&lt;TD class="xl75" style="border-left: medium none;" width="85"&gt;flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/6/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/7/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/8/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/9/2012&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-left: medium none; border-top: medium none;" width="85"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/9/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/10/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/11/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/12/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/13/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/16/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/17/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/18/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/19/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/20/2012&lt;/TD&gt;&lt;TD class="xl73" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-left: medium none; border-top: medium none;" width="75"&gt;5/1/2012&lt;/TD&gt;&lt;TD class="xl74"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-left: medium none; border-top: medium none;" width="75"&gt;5/2/2012&lt;/TD&gt;&lt;TD class="xl74" height="20" style="border-top: medium none;" width="85"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-left: medium none; border-top: medium none;" width="75"&gt;5/3/2012&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: medium none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="301"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="41" width="77"&gt;sector_code&lt;/TD&gt;&lt;TD class="xl67" style="border-left: medium none;" width="75"&gt;date&lt;/TD&gt;&lt;TD class="xl75" style="border-left: medium none;" width="85"&gt;flag&lt;/TD&gt;&lt;TD class="xl76" width="64"&gt;Agg flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/6/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/7/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/8/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;ann&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;3/9/2012&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-left: medium none; border-top: medium none;" width="85"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/9/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/10/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/11/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/12/2012&lt;/TD&gt;&lt;TD class="xl69" style="border-left: medium none; border-top: medium none;" width="85"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/13/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/16/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/17/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/18/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/19/2012&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-left: medium none; border-top: medium none;" width="75"&gt;4/20/2012&lt;/TD&gt;&lt;TD class="xl73" style="border-left: medium none; border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-left: medium none; border-top: medium none;" width="75"&gt;5/1/2012&lt;/TD&gt;&lt;TD class="xl74"&gt; &lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-left: medium none; border-top: medium none;" width="75"&gt;5/2/2012&lt;/TD&gt;&lt;TD align="right" class="xl74" height="20" style="border-top: medium none;" width="85"&gt;&amp;nbsp; &amp;nbsp; 1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" style="border-top: medium none;" width="77"&gt;joe&lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-left: medium none; border-top: medium none;" width="75"&gt;5/3/2012&lt;/TD&gt;&lt;TD class="xl74" style="border-top: medium none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 18:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81944#M23588</guid>
      <dc:creator>hdg</dc:creator>
      <dc:date>2012-04-12T18:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: identify begin of month to current date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81945#M23589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A minor modification on my previous code will do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards truncover;&lt;/P&gt;&lt;P&gt;input var:$ date :mmddyy10. flag;&lt;/P&gt;&lt;P&gt;format date mmddyy10.;&lt;/P&gt;&lt;P&gt;_id=cats(var,year(date),week(date));&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;ann 3/6/2012&lt;/P&gt;&lt;P&gt;ann 3/7/2012&lt;/P&gt;&lt;P&gt;ann 3/8/2012&lt;/P&gt;&lt;P&gt;ann 3/9/2012 1&lt;/P&gt;&lt;P&gt;joe 4/9/2012&lt;/P&gt;&lt;P&gt;joe 4/10/2012&lt;/P&gt;&lt;P&gt;joe 4/11/2012&lt;/P&gt;&lt;P&gt;joe 4/12/2012&lt;/P&gt;&lt;P&gt;joe 4/13/2012&lt;/P&gt;&lt;P&gt;joe 4/16/2012&lt;/P&gt;&lt;P&gt;joe 4/17/2012&lt;/P&gt;&lt;P&gt;joe 4/18/2012&lt;/P&gt;&lt;P&gt;joe 4/19/2012&lt;/P&gt;&lt;P&gt;joe 4/20/2012&lt;/P&gt;&lt;P&gt;joe 5/1/2012&lt;/P&gt;&lt;P&gt;joe 5/2/2012 1&lt;/P&gt;&lt;P&gt;joe 5/3/2012&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 by 1 until (last._id);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;by _id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if flag=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; add_flag=1;&lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 by 1 until (last._id);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;by _id;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if flag=1 then &lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81945#M23589</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-04-12T19:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: identify begin of month to current date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81946#M23590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
infile cards truncover;
input var $ date :mmddyy10. flag;
format date mmddyy10.;
cards;
ann 3/6/2012
ann 3/7/2012
ann 3/8/2012
ann 3/9/2012 1
joe 4/9/2012
joe 4/10/2012
joe 4/11/2012
joe 4/12/2012
joe 4/13/2012
joe 4/16/2012
joe 4/17/2012
joe 4/18/2012
joe 4/19/2012
joe 4/20/2012
joe 5/1/2012
joe 5/2/2012 1
joe 5/3/2012
;
run;
proc sort data=have(where=(flag=1)) out=temp ;by var descending date;run;
proc sort data=temp nodupkey;by var;run;
data x(keep=var _date);
 set temp;
 do _date=mdy(month(date),1,year(date)) to date;
&amp;nbsp; output;
 end;
 format _date mmddyy10.;
run;
data want;
 merge have(in=a) x(rename=(_date=date) in=b);
 by var date;
 aggflag=ifn(b,1,.);
 if a;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Apr 2012 04:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/identify-begin-of-month-to-current-date/m-p/81946#M23590</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-13T04:40:49Z</dc:date>
    </item>
  </channel>
</rss>

