<?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: First observation in a series of columns in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183177#M46652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not really sure what you are asking.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you wanting an aggregate count of 1s for each column? If so, simply sum the columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, are you looking for a count across columns? If so, use SUM (of FLAG:).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Sep 2014 19:20:11 GMT</pubDate>
    <dc:creator>Fugue</dc:creator>
    <dc:date>2014-09-02T19:20:11Z</dc:date>
    <item>
      <title>First observation in a series of columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183176#M46651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp; I have a whole bunch of accounts and I'm trying to find out when the first accident indicator happened from a series of clumns.&amp;nbsp; I can show better below what I mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 100K accounts and each account has flag_1 .. flag_2... up to flag_13.&amp;nbsp; And there is a 0 or a 1 depending when the accident happened.&amp;nbsp; So if the first accident happened in month 1 from the observation period then flag_1 = 1, else 0.. if the accident happened from 3 months form the observation period then flag_3 = 1, else 0.&amp;nbsp; It is possible that one accont has more then 1 flag = 1, depending if they had more than 1 accident.. in total it iss possible to have13 one's.&amp;nbsp; I'm trying to count how many first 1's did it happen for flag_1, and how many first one's for flag_2, and so on to flag_13.&amp;nbsp;&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 18:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183176#M46651</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-09-02T18:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: First observation in a series of columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183177#M46652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not really sure what you are asking.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you wanting an aggregate count of 1s for each column? If so, simply sum the columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, are you looking for a count across columns? If so, use SUM (of FLAG:).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 19:20:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183177#M46652</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2014-09-02T19:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: First observation in a series of columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183178#M46653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sum the columns but only when the 1 is first.&amp;nbsp; It's OK, I figured out a long and dirty way, but it works.&amp;nbsp;&amp;nbsp;&amp;nbsp; Something like:&lt;/P&gt;&lt;P&gt;if acc_flag1 = 0 and acc_flag2 = 0 and acc_flag3 = 0 and acc_flag4 = 0 and acc_flag5 = 0 and acc_flag6 = 0 and acc_flag7 = 0 and acc_flag8 = 0 and acct_flag9 = 0 and acc_flag10 = 0 and acc_flag11 = 0 and acc_flag12 = 0 and acc_flag13 = 1 then DF_13 = 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then continue doing this for each of the 13 flags.. it does get smaller and smaller as I approach acc_flag_1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 19:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183178#M46653</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-09-02T19:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: First observation in a series of columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183179#M46654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array flags {13} acc_flag1 - acc_flag13;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _n_ = 1 to 13;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flags{_n_}=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; first_flag=_n_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _n_=14;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tables first_flag;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you understand arrays and do loops, I imagine you won't have questions about the code.&amp;nbsp; Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 19:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183179#M46654</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-09-02T19:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: First observation in a series of columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183180#M46655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input account flag_1-flag_13;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 0 0 1 1 0 0 0 1 0 1 1 0 1&lt;/P&gt;&lt;P&gt;2 0 0 0 0 0 0 0 0 0 0 0 0 1&lt;/P&gt;&lt;P&gt;3 0 0 0 0 0 0 0 0 0 0 0 0 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want(drop=i);&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt; retain freq1-freq13 0;&lt;/P&gt;&lt;P&gt;array flag(*) flag_1-flag_13;&lt;/P&gt;&lt;P&gt;array freq(*) freq1-freq13;&lt;/P&gt;&lt;P&gt;do i=1 to dim(flag);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flag{i}=1 then do;&lt;/P&gt;&lt;P&gt;freq{i}+1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;freq{i}=0;&lt;/P&gt;&lt;P&gt;leave;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=want;&lt;/P&gt;&lt;P&gt;table freq:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 20:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/First-observation-in-a-series-of-columns/m-p/183180#M46655</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-09-02T20:08:55Z</dc:date>
    </item>
  </channel>
</rss>

