<?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: To  count the number of IDs for which the trans_amt remains same in all observations of that ID. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596909#M171939</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55838"&gt;@paulsud1&lt;/a&gt;&amp;nbsp;hi and welcome to the SAS Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post what you want your desired result to look like? Just like you posted usable example data. And kudos for that&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2019 14:21:48 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-10-16T14:21:48Z</dc:date>
    <item>
      <title>To  count the number of IDs for which the trans_amt remains same in all observations of that ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596907#M171937</link>
      <description>&lt;P&gt;Hi everyone, I am a newbie in SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a large data set with numerous variables two of which are "ID" and "Trans_amt"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to find is to count the number of IDs for which the trans_amt remains same in all observations of that ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; Trans_amt &amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;500&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;500&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;500&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;750&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;750&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;800&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1200&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1500&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1200&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example for ID 1 the Trans_amt is 1000 for all 4 cases right? I want to create a new variable ID_1 where it stored the ID of those only.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 14:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596907#M171937</guid>
      <dc:creator>paulsud1</dc:creator>
      <dc:date>2019-10-16T14:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: To  count the number of IDs for which the trans_amt remains same in all observations of that ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596909#M171939</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55838"&gt;@paulsud1&lt;/a&gt;&amp;nbsp;hi and welcome to the SAS Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post what you want your desired result to look like? Just like you posted usable example data. And kudos for that&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 14:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596909#M171939</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T14:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: To  count the number of IDs for which the trans_amt remains same in all observations of that ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596912#M171940</link>
      <description>&lt;P&gt;This gives you an indicator variable of 1 if the Trans_amt is constant for the entire group and 0 if it has multiple values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Trans_amt;
datalines;
1 1000
1 1000
1 1000
1 1000
2 500
2 500
2 500
3 750
3 750
3 800
4 1200
4 1500
4 1200
;

proc sql;
    create table want as
    select *, (count (distinct Trans_amt))=1 as ind
    from have 
    group by ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 14:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596912#M171940</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T14:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: To  count the number of IDs for which the trans_amt remains same in all observations of that ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596929#M171950</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55838"&gt;@paulsud1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure whether this code could satisfy your request&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID Trans_amt;
	cards;
1 1000
1 1000
1 1000
2 500
2 500
2 500
3 750
3 750
3 800
4 1200
4 1500
4 1200
;
run;

/* Retrieve id for which all Trans_amt are the same */
proc sort data=have;
	by ID Trans_amt;
run;

data ID_list;
	set have;
	by ID;
	if first.id or Trans_amt=lag(Trans_amt) then id_1=1;
	else id_1=0;
	if last.id then output;
	keep id id_1;
run;

/* Merge with original dataset */
proc sort data=ID_list;
	by ID ;
run;

data want;
	merge have ID_list;
	by ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 14:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-count-the-number-of-IDs-for-which-the-trans-amt-remains-same/m-p/596929#M171950</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-10-16T14:53:03Z</dc:date>
    </item>
  </channel>
</rss>

