<?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: How do I replace one dataset's ID column with a second dataset's ID column? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930867#M41884</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253026"&gt;@cosmid&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the first, second, third, ... ID in the first dataset (let's call it HAVE1) is replaced by the first, second, third, ... ID in the second dataset (HAVE2), respectively?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=_);
retain id; /* redundant if order of variables is not important */
set have1(rename=(id=_));
if value='01' then set have2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Jun 2024 21:28:09 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-06-04T21:28:09Z</dc:date>
    <item>
      <title>How do I replace one dataset's ID column with a second dataset's ID column?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930864#M41882</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the layout for the first dataset with the ID column that I want to replace:&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; value&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp;01&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp;02&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp;03&lt;/P&gt;
&lt;P&gt;130&amp;nbsp; &amp;nbsp; &amp;nbsp;01&lt;/P&gt;
&lt;P&gt;131&amp;nbsp; &amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;131&amp;nbsp; &amp;nbsp; &amp;nbsp; 02&lt;/P&gt;
&lt;P&gt;133&amp;nbsp; &amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;136&amp;nbsp; &amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;136&amp;nbsp; &amp;nbsp; &amp;nbsp; 02&lt;/P&gt;
&lt;P&gt;136&amp;nbsp; &amp;nbsp; &amp;nbsp; 03&lt;/P&gt;
&lt;P&gt;Please note that the ID will change once the Value column starts at 01 again&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the second dataset with the ID column that I want:&lt;/P&gt;
&lt;P&gt;ID&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;P&gt;9&lt;/P&gt;
&lt;P&gt;15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The updated dataset should be the following:&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; value&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01&lt;/P&gt;
&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01&lt;/P&gt;
&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02&lt;/P&gt;
&lt;P&gt;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01&lt;/P&gt;
&lt;P&gt;15&amp;nbsp; &amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;15&amp;nbsp; &amp;nbsp; &amp;nbsp; 02&lt;/P&gt;
&lt;P&gt;15&amp;nbsp; &amp;nbsp; &amp;nbsp; 03&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 20:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930864#M41882</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2024-06-04T20:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace one dataset's ID column with a second dataset's ID column?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930865#M41883</link>
      <description>&lt;P&gt;What information in the two data sets tells us that the 130 is supposed to be replaced by the 3?&lt;/P&gt;
&lt;P&gt;How many of these values do you have if this is just an example question? I am afraid that without some more to go on the ids in the second set are pretty much useless.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 21:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930865#M41883</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-04T21:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace one dataset's ID column with a second dataset's ID column?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930867#M41884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253026"&gt;@cosmid&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the first, second, third, ... ID in the first dataset (let's call it HAVE1) is replaced by the first, second, third, ... ID in the second dataset (HAVE2), respectively?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=_);
retain id; /* redundant if order of variables is not important */
set have1(rename=(id=_));
if value='01' then set have2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2024 21:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930867#M41884</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-06-04T21:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace one dataset's ID column with a second dataset's ID column?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930869#M41885</link>
      <description>&lt;P&gt;Not sure why but here you go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
   input ID  value:$2.;
   cards;
123     01
123     02
123     03
130     01
131      01
131      02
133      01
136      01
136      02
136      03
;;;;
   run;
data two;
   input ID;
   cards;
1
3
5
9
15       
;;;;   
   run;

data want;
   set one;
   by id;
   if first.id then set two(rename=ID=XID);
   id = xid;
   drop xid;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 110px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97014i0ABBF2839F9EAF21/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 21:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930869#M41885</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-04T21:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace one dataset's ID column with a second dataset's ID column?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930876#M41886</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
   input ID  value:$2.;
   cards;
123     01
123     02
123     03
130     01
131      01
131      02
133      01
136      01
136      02
136      03
;;;;
   run;
data two;
   input ID;
   cards;
1
3
5
9
15    
;;;;   
   run;

data key;
 set one;
 by id;
 if first.id;
 keep id;
run;
data fmt;
 retain fmtname 'fmt' type 'i';
 merge key(in=ina keep=id rename=(id=start)) two(rename=(id=label));
 if ina;
run;
proc format cntlin=fmt;
run;
data want;
 set one(rename=(id=_id));
 id=input(_id,fmt.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jun 2024 01:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-replace-one-dataset-s-ID-column-with-a-second-dataset-s/m-p/930876#M41886</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-06-05T01:35:41Z</dc:date>
    </item>
  </channel>
</rss>

