<?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: Find in order variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268635#M53225</link>
    <description>&lt;P&gt;Two questions ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like SUBJ should be important here.&amp;nbsp; Must all grades be for the same SUBJ as well as for the same ID?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would this pattern be one that you want:&amp;nbsp; A B B C&lt;/P&gt;
&lt;P&gt;(Or perhaps it's not a possible pattern because "B" can't change to "B".)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 May 2016 18:47:04 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-05-05T18:47:04Z</dc:date>
    <item>
      <title>'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268523#M53159</link>
      <description>&lt;P&gt;I need to find who has in order A-B-C. Please check the table for example;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;term &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grade &amp;nbsp; &amp;nbsp; &amp;nbsp;subj &amp;nbsp; &amp;nbsp; &amp;nbsp;num&lt;/P&gt;
&lt;P&gt;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;332 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;333 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What i need fromthis table is &amp;nbsp;id : 11 AND 15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output should be like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; term &amp;nbsp; subj&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; 2005 &amp;nbsp; 232&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp;2010 &amp;nbsp; &amp;nbsp;130&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So i need list the id's that had Grade of 'A' in it then was changed to 'B' then it was changed to 'C' .&lt;/P&gt;
&lt;P&gt;Num could be in order. It dosen't have to start from 1, it could be 1 or 2 or 3, etc. But it &amp;nbsp;should be in order A then B then C&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 17:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268523#M53159</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-05-05T17:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268531#M53163</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;select distinct id, term, subj from have&lt;BR /&gt;group by id&lt;BR /&gt;having count(distinct grade)=3;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 14:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268531#M53163</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-05-05T14:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268534#M53165</link>
      <description>Data step, by Id,  and use retain to keep track of the previous grade.&lt;BR /&gt;You probably need to use first. and last. logic as well.</description>
      <pubDate>Thu, 05 May 2016 14:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268534#M53165</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-05-05T14:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268537#M53167</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42042"&gt;@stat_sas&lt;/a&gt;: that will give you students with three grades, but not necessarily in A-B-C order.&lt;BR /&gt;This problem is row order based, which suits a data step better, whereas SQL is column based and usually having more problems keeping track of row order.</description>
      <pubDate>Thu, 05 May 2016 14:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268537#M53167</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-05-05T14:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268541#M53169</link>
      <description>&lt;P&gt;Not tested as tets data not in datastep form, but somethign like:&lt;/P&gt;
&lt;PRE&gt;data want (drop=res grade);
  set have;
  by id;
  length res $10;
  if first.id then res="";
  res=cats(res,grade);
  if last.id and res in ("ABC","ACB","BAC","BCA","CAB","CBA") then output;
run;&lt;/PRE&gt;
&lt;P&gt;Or another option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select distinct A.*
  from   HAVE A
  where  exists(select distinct ID from HAVE where ID=A.ID and GRADE="A")
    and  exists(select distinct ID from HAVE where ID=A.ID and GRADE="B")
    and  exists(select distinct ID from HAVE where ID=A.ID and GRADE="C");
quit;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2016 14:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268541#M53169</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-05T14:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268547#M53172</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH﻿&lt;/a&gt;: True, If order matters then data step would be a better option.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;BR /&gt;by id grade;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(keep=id term subj);&lt;BR /&gt;set have;&lt;BR /&gt;by id grade;&lt;BR /&gt;if first.id then cnt=0;&lt;BR /&gt;cnt+1;&lt;BR /&gt;if cnt=3;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 14:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268547#M53172</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-05-05T14:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268573#M53174</link>
      <description>&lt;P&gt;Here is another option, concatenate all the grade within same ID following the data order, then check 'ABC':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input id          term        grade$      subj;
	cards;
10         2002        D            332
10         2002        A              333
11         2005        A             232
11         2005        B             232
11         2005        C             232
15         2010       A              130
15         2010       B               130
;

data want;
	length _cat $ 100;

	do until (last.term);
		set have;
		by id term notsorted;
		_cat=cats(_cat,grade);
	end;

	if find(_cat,'ABC') then
		output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2016 15:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268573#M53174</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-05-05T15:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268582#M53176</link>
      <description>&lt;P&gt;That code doesn't work for same term&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 15:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268582#M53176</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-05-05T15:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268584#M53177</link>
      <description>&lt;P&gt;It does now.&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 15:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268584#M53177</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-05-05T15:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268586#M53178</link>
      <description>&lt;P&gt;it works for the table i send example, but in my bug table gives me nothing in this code.&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 15:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268586#M53178</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-05-05T15:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268589#M53179</link>
      <description>&lt;P&gt;Assuming the "want" data is where the ID is in sequence AND the sequence of grades is exactly as proposed, A, B and C in order this may work for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   if id=lag(id) and Id=Lag2(id) and grade='C' and lag(grade)='B' and Lag2(grade)='A';
   drop grade;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2016 15:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268589#M53179</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-05T15:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268621#M53183</link>
      <description>&lt;P&gt;I don;t know the Lag means but with this way i got nothing. Actually i make it better, i renewed my example table . It should be same id same term an same subj, but it should be in order grade.&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 17:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268621#M53183</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-05-05T17:43:24Z</dc:date>
    </item>
    <item>
      <title>Find in order variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268633#M53224</link>
      <description>&lt;P&gt;I need to find who has in order A-B-C. Please check the table for example;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;term &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grade &amp;nbsp; &amp;nbsp; &amp;nbsp;subj &amp;nbsp; &amp;nbsp; &amp;nbsp;num&lt;/P&gt;
&lt;P&gt;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;332 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;333 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 232 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;130 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What i need fromthis table is &amp;nbsp;id : 11 AND 15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output should be like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; term &amp;nbsp; subj&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; 2005 &amp;nbsp; 232&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp;2010 &amp;nbsp; &amp;nbsp;130&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So i need list the id's that had Grade of 'A' in it then was changed to 'B' then it was changed to 'C' .&lt;/P&gt;
&lt;P&gt;Num could be in order. It dosen't have to start from 1, it could be 1 or 2 or 3, etc. But it &amp;nbsp;should be in order A then B then C&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 18:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268633#M53224</guid>
      <dc:creator>lerdem</dc:creator>
      <dc:date>2016-05-05T18:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find in order variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268635#M53225</link>
      <description>&lt;P&gt;Two questions ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like SUBJ should be important here.&amp;nbsp; Must all grades be for the same SUBJ as well as for the same ID?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would this pattern be one that you want:&amp;nbsp; A B B C&lt;/P&gt;
&lt;P&gt;(Or perhaps it's not a possible pattern because "B" can't change to "B".)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 18:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268635#M53225</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-05T18:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: 'A' in it then was changed to 'B' then it was changed to 'C' .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268639#M53186</link>
      <description>&lt;P&gt;Please show the exact code you ran.&lt;/P&gt;
&lt;P&gt;The example I provided works with both sets of example data you have provided.&lt;/P&gt;
&lt;P&gt;So there may be something else going on in your data that you are not providing to us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LAG and the related LAGn functions allow you to examine previous values of your data. Lag (or Lag1) looks at the value of the variable in the previous record, Lag2 in the record before that.&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 18:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268639#M53186</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-05T18:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Find in order variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268653#M53226</link>
      <description>&lt;P&gt;Third question: Isn't this the same question as you asked in &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/td-p/268523" target="_blank"&gt;the other thread&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 19:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268653#M53226</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-05T19:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find in order variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268755#M53227</link>
      <description>&lt;P&gt;Please don't post the same question multiple times. &amp;nbsp;To get a good response to your question post: test data, in the form of a datastep that covers your actual data and any differences - we can only work with what you give us. &amp;nbsp;Also post, what you want the output to look like, then any additional logic which may help. &amp;nbsp;Looking at your latest post, my post originally that was ignored should give you the result you want:&lt;/P&gt;
&lt;PRE&gt;data have;
  input id term grade $ subj num;
  datalines;
10         2002        D            332        1 
10         2002        A              333       2
11         2005        C             232       1 
11         2005        A             232         2
11         2005        B             232        3
11         2005        C             232       4
15         2010       A              130        1
15         2010       B               130        2
15         2010       C              130        3 
;
run;
data want (keep=id term subj);
  length res $10;
  set have;
  retain res;
  by id term;
  if first.term then res="";
  res=cats(res,grade);
  if last.term and index(res,"ABC")&amp;gt;0 then output;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 08:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-in-it-then-was-changed-to-B-then-it-was-changed-to-C/m-p/268755#M53227</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-06T08:37:24Z</dc:date>
    </item>
  </channel>
</rss>

