<?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: differen value within second by variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491380#M128843</link>
    <description>I wanted to use first. and last.</description>
    <pubDate>Thu, 30 Aug 2018 18:54:26 GMT</pubDate>
    <dc:creator>SASSLICK001</dc:creator>
    <dc:date>2018-08-30T18:54:26Z</dc:date>
    <item>
      <title>differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491301#M128817</link>
      <description>&lt;P&gt;Hi I have the following&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id1 id2&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;02&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;02&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;02&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I ideintify the different value id2 within id1?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 15:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491301#M128817</guid>
      <dc:creator>SASSLICK001</dc:creator>
      <dc:date>2018-08-30T15:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491306#M128821</link>
      <description>&lt;P&gt;This both identifies and counts for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables id1 * id2 / list missing;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 15:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491306#M128821</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-30T15:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491380#M128843</link>
      <description>I wanted to use first. and last.</description>
      <pubDate>Thu, 30 Aug 2018 18:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491380#M128843</guid>
      <dc:creator>SASSLICK001</dc:creator>
      <dc:date>2018-08-30T18:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491395#M128852</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43230"&gt;@SASSLICK001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I wanted to use first. and last.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It would help to show what you expect for output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe something like ?&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   by id1 id2;
   if first.id2;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Aug 2018 19:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491395#M128852</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-30T19:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491687#M129012</link>
      <description>&lt;P&gt;I want to create a flag where the value changes per change in value for id2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;expected output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id1 id2&amp;nbsp; flag&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; x&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;01&amp;nbsp; x&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01&amp;nbsp;&amp;nbsp;y&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;02&amp;nbsp;&amp;nbsp;z&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;02&amp;nbsp;&amp;nbsp;z&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;02&amp;nbsp;&amp;nbsp;z&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 16:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491687#M129012</guid>
      <dc:creator>SASSLICK001</dc:creator>
      <dc:date>2018-08-31T16:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491698#M129017</link>
      <description>&lt;P&gt;Assuming your data is sorted by ID1 and ID2 as implied by your example:&lt;/P&gt;
&lt;PRE&gt;data have;
input id1 $ id2  $;
datalines;
01  x 
01  x 
01  y 
02  z 
02  z 
02  z 
;
run;
data want;
   set have;
   by id1 id2;
   if first.id1 then flag=0;
   else flag = first.id2;
run;&lt;/PRE&gt;
&lt;P&gt;I prefer the 0/1 coding as 0 means 'not a change' in this case and there are some advantages that I can count the number of changes in id1 by getting a sum of the flag variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is not sorted then you need to provide a more realistic example of the data.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 17:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491698#M129017</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-31T17:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: differen value within second by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491742#M129038</link>
      <description>&lt;P&gt;For that result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by id1 id2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id1 id2;&lt;/P&gt;
&lt;P&gt;if first.id1 then flag=1;&lt;/P&gt;
&lt;P&gt;else if first.id2 then flag + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/differen-value-within-second-by-variable/m-p/491742#M129038</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-31T20:25:13Z</dc:date>
    </item>
  </channel>
</rss>

