<?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: Replacing IDs with the same value :Part2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758748#M239646</link>
    <description>&lt;P&gt;have a look at&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have(rename= (subjid = _subjid));
   by id notsorted;
   
   length 
      subjid $ 8 
      o_subjid $ 6
      count 8
   ;
   
   retain o_subjid count;
   
   if first.id then do;
      o_subjid = _subjid;
      count = 0;
   end;

   if not (first.id and last.id) then do;
      subjid = catx('_', o_subjid, byte(65 + count));
      count + 1;
   end;
   else do;
      subjid = o_subjid;
   end;
   
   drop o_subjid _subjid count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 02 Aug 2021 11:15:52 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2021-08-02T11:15:52Z</dc:date>
    <item>
      <title>Replacing IDs with the same value :Part2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758734#M239634</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;I did ask this question previously about how ids with the same values the same subjid are assigned :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id 2. subjid $6. var1 $2. var2 $2. ;
datalines;
1  pat_1 A B
14 pat_2 C D
14 pat_3 E F
14 pat_4 G H
2  pat_5 I J
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and got this reply as solution:&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data want;
   set have(rename= (subjid = _subjid));
   by id notsorted;
   
   length subjid $ 6;
   retain subjid;
   
   if first.id then subjid = _subjid;
   
   drop _subjid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I want the first id 14 to have a subjid &lt;STRONG&gt;pat_2_A&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; the second id 14 to have a subjid &lt;STRONG&gt;pat_2_B&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and the&amp;nbsp;&amp;nbsp;third id 14 to have a subjid &lt;STRONG&gt;pat_2_C&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of just pat_2, how to I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 10:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758734#M239634</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-08-02T10:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing IDs with the same value :Part2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758736#M239635</link>
      <description>&lt;P&gt;Not clear, what you expect as value for subjid, if there is only one observation for the id. Please explain.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 10:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758736#M239635</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-08-02T10:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing IDs with the same value :Part2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758746#M239644</link>
      <description>&lt;P&gt;Am expecting something like this:&lt;BR /&gt;&lt;BR /&gt;id var1 var2 subjid&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; A&amp;nbsp; B&amp;nbsp; pat_1&lt;BR /&gt;14&amp;nbsp; C D&amp;nbsp; pat_2_A&lt;BR /&gt;14&amp;nbsp; E F&amp;nbsp; &amp;nbsp;pat_2_B&lt;BR /&gt;14&amp;nbsp; G H&amp;nbsp; pat_2_C&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; I J&amp;nbsp; &amp;nbsp; pat_5&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 11:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758746#M239644</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-08-02T11:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing IDs with the same value :Part2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758748#M239646</link>
      <description>&lt;P&gt;have a look at&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have(rename= (subjid = _subjid));
   by id notsorted;
   
   length 
      subjid $ 8 
      o_subjid $ 6
      count 8
   ;
   
   retain o_subjid count;
   
   if first.id then do;
      o_subjid = _subjid;
      count = 0;
   end;

   if not (first.id and last.id) then do;
      subjid = catx('_', o_subjid, byte(65 + count));
      count + 1;
   end;
   else do;
      subjid = o_subjid;
   end;
   
   drop o_subjid _subjid count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Aug 2021 11:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758748#M239646</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-08-02T11:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing IDs with the same value :Part2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758754#M239650</link>
      <description>perfect, thank you.</description>
      <pubDate>Mon, 02 Aug 2021 11:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-IDs-with-the-same-value-Part2/m-p/758754#M239650</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-08-02T11:46:42Z</dc:date>
    </item>
  </channel>
</rss>

