<?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: substituting/ replacing a record with another in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44793#M11813</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... just another thought on this.&amp;nbsp; If the observations are not sorted in step order&lt;/P&gt;&lt;P&gt;within a CID, you could try the following.&amp;nbsp; The first pass (first SET HAVE) finds the&lt;/P&gt;&lt;P&gt;largest value of STEP that is not 9.&amp;nbsp; The second pass replaces the 9s with&lt;/P&gt;&lt;P&gt;that largest value from the first pass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data need;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do until (last.cid);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set have (in=a where=(step ne 9)) have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by&amp;nbsp; cid;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if a&amp;nbsp; then big = max(big,step);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if ^a then do; step = ifn(step ne 9, step, big); output; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;drop big;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on ...&lt;/P&gt;&lt;P&gt;Interleaving a Dataset with Itself: How and Why&lt;/P&gt;&lt;P&gt;by Howard Schreier&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.nesug.org/proceedings/nesug03/cc/cc002.pdf"&gt;http://www.nesug.org/proceedings/nesug03/cc/cc002.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Jul 2011 18:35:00 GMT</pubDate>
    <dc:creator>MikeZdeb</dc:creator>
    <dc:date>2011-07-25T18:35:00Z</dc:date>
    <item>
      <title>substituting/ replacing a record with another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44790#M11810</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a data set tab129&lt;BR /&gt;
&lt;BR /&gt;
CID STEP TCODE&lt;BR /&gt;
001 1 aa000&lt;BR /&gt;
001 1 aa002&lt;BR /&gt;
001 2 aa000&lt;BR /&gt;
001 2 aa001&lt;BR /&gt;
001 2 aa003&lt;BR /&gt;
001 9 aa000&lt;BR /&gt;
001 9 aa004&lt;BR /&gt;
002 1 aa000&lt;BR /&gt;
002 1 aa002&lt;BR /&gt;
002 1 aa003&lt;BR /&gt;
002 1 aa004&lt;BR /&gt;
002 9 aa002&lt;BR /&gt;
002 9 aa005&lt;BR /&gt;
002 9 aa006&lt;BR /&gt;
&lt;BR /&gt;
and so on. Here value for step 9 is the event which is not been defined in step 1 or 2. I need the TCODE. I need to convert 9 into the maximum step number for that CID. (ie), for CID 001, 9 should be changed into 2 as that is the highest step for that CID, but for CID 002, 9 takes the value 1.&lt;BR /&gt;
&lt;BR /&gt;
How to deal with this issue?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance,&lt;BR /&gt;
Sandy.</description>
      <pubDate>Thu, 21 Jan 2010 20:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44790#M11810</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-01-21T20:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: substituting/ replacing a record with another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44791#M11811</link>
      <description>It sounds as though you have the "process flow logic" and rules to manipulate the data values.  With SAS, I would suggest you look at using either a matched-MERGE or UPDATE (using a DATA step technique, with your updates in a separate file).&lt;BR /&gt;
&lt;BR /&gt;
Your task will be to develop a SAS DATA step approach (likely with using PROC SORT and maybe other PROCs) to get your "updates" created based on your stated criteria.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search for this topic/post:&lt;BR /&gt;
&lt;BR /&gt;
update master file site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 21 Jan 2010 20:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44791#M11811</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-21T20:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: substituting/ replacing a record with another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44792#M11812</link>
      <description>[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   input CID $ STEP TCODE $;&lt;BR /&gt;
   cards;&lt;BR /&gt;
001 1 aa000&lt;BR /&gt;
001 1 aa002&lt;BR /&gt;
001 2 aa000&lt;BR /&gt;
001 2 aa001&lt;BR /&gt;
001 2 aa003&lt;BR /&gt;
001 9 aa000&lt;BR /&gt;
001 9 aa004&lt;BR /&gt;
002 1 aa000&lt;BR /&gt;
002 1 aa002&lt;BR /&gt;
002 1 aa003&lt;BR /&gt;
002 1 aa004&lt;BR /&gt;
002 9 aa002&lt;BR /&gt;
002 9 aa005&lt;BR /&gt;
002 9 aa006&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
data need;&lt;BR /&gt;
   do until(last.cid);&lt;BR /&gt;
      set have;&lt;BR /&gt;
      by cid step;&lt;BR /&gt;
      if first.step and step ne 9 then s=step;&lt;BR /&gt;
      if step eq 9 then step=s;&lt;BR /&gt;
      output;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 21 Jan 2010 21:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44792#M11812</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-01-21T21:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: substituting/ replacing a record with another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44793#M11813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... just another thought on this.&amp;nbsp; If the observations are not sorted in step order&lt;/P&gt;&lt;P&gt;within a CID, you could try the following.&amp;nbsp; The first pass (first SET HAVE) finds the&lt;/P&gt;&lt;P&gt;largest value of STEP that is not 9.&amp;nbsp; The second pass replaces the 9s with&lt;/P&gt;&lt;P&gt;that largest value from the first pass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data need;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do until (last.cid);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set have (in=a where=(step ne 9)) have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by&amp;nbsp; cid;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if a&amp;nbsp; then big = max(big,step);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if ^a then do; step = ifn(step ne 9, step, big); output; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;drop big;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on ...&lt;/P&gt;&lt;P&gt;Interleaving a Dataset with Itself: How and Why&lt;/P&gt;&lt;P&gt;by Howard Schreier&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.nesug.org/proceedings/nesug03/cc/cc002.pdf"&gt;http://www.nesug.org/proceedings/nesug03/cc/cc002.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 18:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44793#M11813</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-07-25T18:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: substituting/ replacing a record with another</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44794#M11814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data have;
&amp;nbsp;&amp;nbsp; input CID $ STEP TCODE $;
&amp;nbsp;&amp;nbsp; cards;
001 1 aa000
001 1 aa002
001 2 aa000
001 2 aa001
001 2 aa003
001 9 aa000
001 9 aa004
002 1 aa000
002 1 aa002
002 1 aa003
002 1 aa004
002 9 aa002
002 9 aa005
002 9 aa006
;;;;
&amp;nbsp;&amp;nbsp; run;
data want(drop=_step);
 set have;
 retain _step;
 if step ne 9 then _step=step;
&amp;nbsp; else step=_step;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&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>Tue, 26 Jul 2011 04:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/substituting-replacing-a-record-with-another/m-p/44794#M11814</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-26T04:50:58Z</dc:date>
    </item>
  </channel>
</rss>

