<?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 observations of one dataset with the values of another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525987#M143158</link>
    <description>&lt;P&gt;Ok, so we need to expand the format solution.&lt;/P&gt;
&lt;P&gt;One way would be to combine the two values that determine the outcome into a single variable and create the format for this.&lt;/P&gt;
&lt;P&gt;Or we create multiple formats for the ID's, which I have done here, and use the putc() instead of the put() function (putc() and putn() accept expressions as formats, while put() only accepts a literal format name):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Dataset1;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1 : $60.
	Manager2 : $60.
	Manager3 : $60. ;
format Date_Month mmddyy10. ;
datalines;
AB00046,06-30-2016,Ronald Baron,Bill F. Baron,
AB00046,07-31-2016,Ronald Baron,Bill F. Baron,
AB00046,08-31-2016,Ronald Baron,Bill F. Baron,
AB00046,09-30-2016,Ronald Baron,Bill F. Baron,
AB00046,10-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,11-30-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,12-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,01-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,02-28-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,03-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,04-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,05-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,06-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,07-31-2017,Ronald Baron,Bill F. Baron,
AB00046,08-31-2017,Ronald Baron,Bill F. Baron,
AB00050,04-30-2016,
AB00050,05-31-2016,
AB00050,06-30-2016,Sharon
AB00050,07-31-2016,Sharon,Tim S.
AB00050,08-31-2016,Sharon,Tim S.
AB00050,09-30-2016,Sharon,Tim S. 
;
run;

Data Dataset2;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Name_Manager : $60.
	Gender ;
datalines;
AB00046,Ronald Baron,0
AB00046,Bill F. Baron,0
AB00046,Tim S.,0
AB00050,Sharon,1
AB00050,Tim S.,0
;
run;


proc sort data=dataset2;
by id;
run;

data cntlin;
set dataset2;
by id;
fmtname = strip(id) !! '_';
type = 'C';
start = name_manager;
label = put(gender,best.);
output;
if last.id
then do;
  name_manager = 'other';
  hlo = 'O';
  label = '';
  output;
end;
drop id name_manager gender;
run;

proc format cntlin=cntlin;
run;

data want;
set dataset1;
array manager {*} manager:;
do i = 1 to dim(manager);
  manager {i} = putc(manager{i},strip(id) !! '_');
end;
drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The appended underline is necessary because your ID values end with numbers. Similarly, you would neet to prepend an underline or a character if ID started with a digit.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jan 2019 07:42:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-01-10T07:42:19Z</dc:date>
    <item>
      <title>Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525347#M142943</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset1 where columns are basically managers' names attached to various dates. This is my master/main dataset. The other dataset2&amp;nbsp;has a gender column of these managers, so&amp;nbsp;one column is names of these managers and parallel column is the gender (converted in numeric i.e. 0 and 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a "New_dataset" which should be similar to Dataset1, but the names (character variable) must be replaced with the gender variable from Dataset2. Please see a sample below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Dataset1;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1 : $60.
	Manager2 : $60.
	Manager3 : $60. ;
format Date_Month mmddyy10. ;
datalines;
AB00046,06-30-2016,Ronald Baron,Bill F. Baron,
AB00046,07-31-2016,Ronald Baron,Bill F. Baron,
AB00046,08-31-2016,Ronald Baron,Bill F. Baron,
AB00046,09-30-2016,Ronald Baron,Bill F. Baron,
AB00046,10-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,11-30-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,12-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,01-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,02-28-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,03-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,04-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,05-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,06-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,07-31-2017,Ronald Baron,Bill F. Baron,
AB00046,08-31-2017,Ronald Baron,Bill F. Baron,
AB00050,04-30-2016,
AB00050,05-31-2016,
AB00050,06-30-2016,Sharon
AB00050,07-31-2016,Sharon,Tim S.
AB00050,08-31-2016,Sharon,Tim S.
AB00050,09-30-2016,Sharon,Tim S. 
; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Dataset2;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Name_Manager : $60.
	Gender ;
datalines;
AB00046,Ronald Baron,0
AB00046,Bill F. Baron,0
AB00046,Tim S.,0
AB00050,Sharon,1
AB00050,Tim S.,0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Dataset_Want;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1
	Manager2
	Manager3 ;
format Date_Month mmddyy10. ;
datalines;
AB00046,06-30-2016,0,0,
AB00046,07-31-2016,0,0,
AB00046,08-31-2016,0,0,
AB00046,09-30-2016,0,0,
AB00046,10-31-2016,0,0,0
AB00046,11-30-2016,0,0,0
AB00046,12-31-2016,0,0,0
AB00046,01-31-2017,0,0,0
AB00046,02-28-2017,0,0,0
AB00046,03-31-2017,0,0,0
AB00046,04-30-2017,0,0,0
AB00046,05-31-2017,0,0,0
AB00046,06-30-2017,0,0,0
AB00046,07-31-2017,0,0,
AB00046,08-31-2017,0,0,
AB00050,04-30-2016,
AB00050,05-31-2016,
AB00050,06-30-2016,1
AB00050,07-31-2016,1,0
AB00050,08-31-2016,1,0
AB00050,09-30-2016,1,0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Please Guide me in this regard. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 04:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525347#M142943</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-01-10T04:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525348#M142953</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;: your help will be really appreciated.</description>
      <pubDate>Tue, 08 Jan 2019 08:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525348#M142953</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-01-08T08:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525358#M142958</link>
      <description>&lt;P&gt;Create a format from dataset2, and apply it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cntlin;
set dataset2 end=eof;
fmtname = 'mygender';
type = 'C';
start = name_manager;
label = put(gender,best.);
output;
if eof
then do;
  name_manager = 'other';
  hlo = 'O';
  label = '';
  output;
end;
drop id name_manager gender;
run;

proc format cntlin=cntlin;
run;

data want;
set dataset1;
array manager {*} manager:;
do i = 1 to dim(manager);
  manager {i} = put(manager{i},$mygender.);
end;
drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 09:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525358#M142958</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-08T09:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525360#M142960</link>
      <description>&lt;P&gt;There are many way to solve a problem like this. Here is a PROC FORMAT Approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fmt;
   set Dataset2(rename=(Name_Manager=start Gender=label)) end=eof;
   retain fmtname "MngFmt" type "c";
   output;
   if eof then do;
      start=""; Label="";
      HLO="O"; output;
   end;
run;

proc format library=work cntlin=fmt;
run;

data want;
   set Dataset1;
   Manager1=input(put(Manager1, $MngFmt.), 8.);
   Manager2=input(put(Manager2, $MngFmt.), 8.);
   Manager3=input(put(Manager3, $MngFmt.), 8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 09:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525360#M142960</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-08T09:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525600#M143021</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; : Thanks for your reply. But when I run "proc format cntlin=cntlin;" statement, the Error says: "ERROR: For format $MYGENDER, this range is repeated, or values overlap". Therefore, for "Want" dataset when I run data step, the Error is as follows: " The format $MYGENDER was not found or could not be loaded".&lt;BR /&gt;Actually, several managers' names are repeated in dataset2. So there can be cases with same manager name but different ID or in few cases even with the same ID the name is repeated twice. Is there a way to solve this issue?</description>
      <pubDate>Tue, 08 Jan 2019 22:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525600#M143021</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-01-08T22:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525601#M143022</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;: Thanks but in my dataset2 managers' names are repeating so when I run "proc format" statement, I receive the following Error: "ERROR: For format $MNGFMT, this range is repeated, or values overlap:". Also is there a way to replace all the statements like "Manager1=input(put(Manager1, $MngFmt.), 8.);" with something else, because I have around 100 columns in Dataset1 i.e. Manager1 - Manager100.</description>
      <pubDate>Tue, 08 Jan 2019 22:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525601#M143022</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-01-08T22:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525619#M143025</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166516"&gt;@Saba1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Here a hash approach which also looks for a matching ID column and not only names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=_:);
  set Dataset1;
  array Managers {*} Manager:;

  if _n_=1 then 
    do;
      if 0 then set dataset2(keep=Name_Manager);
      drop Name_Manager Gender;
      dcl hash h1(dataset:'dataset2');
      h1.defineKey('id','Name_Manager');
      h1.defineData('Gender');
      h1.defineDone();
    end;

  do _i=1 to dim(managers);
    if h1.find(key:id, key:managers[_i]) = 0 then managers[_i]=put(Gender,f1.);
    else call missing(managers[_i]);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 23:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525619#M143025</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-08T23:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525650#M143042</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166516"&gt;@Saba1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; : Thanks for your reply. But when I run "proc format cntlin=cntlin;" statement, the Error says: "ERROR: For format $MYGENDER, this range is repeated, or values overlap". Therefore, for "Want" dataset when I run data step, the Error is as follows: " The format $MYGENDER was not found or could not be loaded".&lt;BR /&gt;&lt;STRONG&gt;Actually, several managers' names are repeated in dataset2. So there can be cases with same manager name but different ID or in few cases even with the same ID the name is repeated twice. Is there a way to solve this issue?&lt;/STRONG&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post test-data that matches your real data. With the data posted creating the format does not throw any error message.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 07:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525650#M143042</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-01-09T07:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525664#M143047</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166516"&gt;@Saba1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; : Thanks for your reply. But when I run "proc format cntlin=cntlin;" statement, the Error says: "ERROR: For format $MYGENDER, this range is repeated, or values overlap". Therefore, for "Want" dataset when I run data step, the Error is as follows: " The format $MYGENDER was not found or could not be loaded".&lt;BR /&gt;Actually, several managers' names are repeated in dataset2. So there can be cases with same manager name but different ID or in few cases even with the same ID the name is repeated twice. Is there a way to solve this issue?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With the data presented, the code works. Please post complete example data that illustrates your issues sufficiently.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 09:52:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525664#M143047</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-09T09:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525957#M143137</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;Please see the updated data sample. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 02:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525957#M143137</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-01-10T02:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525958#M143138</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;: I have updated the sample data. You can see now. Thanks</description>
      <pubDate>Thu, 10 Jan 2019 02:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525958#M143138</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-01-10T02:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing observations of one dataset with the values of another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525987#M143158</link>
      <description>&lt;P&gt;Ok, so we need to expand the format solution.&lt;/P&gt;
&lt;P&gt;One way would be to combine the two values that determine the outcome into a single variable and create the format for this.&lt;/P&gt;
&lt;P&gt;Or we create multiple formats for the ID's, which I have done here, and use the putc() instead of the put() function (putc() and putn() accept expressions as formats, while put() only accepts a literal format name):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Dataset1;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1 : $60.
	Manager2 : $60.
	Manager3 : $60. ;
format Date_Month mmddyy10. ;
datalines;
AB00046,06-30-2016,Ronald Baron,Bill F. Baron,
AB00046,07-31-2016,Ronald Baron,Bill F. Baron,
AB00046,08-31-2016,Ronald Baron,Bill F. Baron,
AB00046,09-30-2016,Ronald Baron,Bill F. Baron,
AB00046,10-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,11-30-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,12-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,01-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,02-28-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,03-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,04-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,05-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,06-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,07-31-2017,Ronald Baron,Bill F. Baron,
AB00046,08-31-2017,Ronald Baron,Bill F. Baron,
AB00050,04-30-2016,
AB00050,05-31-2016,
AB00050,06-30-2016,Sharon
AB00050,07-31-2016,Sharon,Tim S.
AB00050,08-31-2016,Sharon,Tim S.
AB00050,09-30-2016,Sharon,Tim S. 
;
run;

Data Dataset2;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Name_Manager : $60.
	Gender ;
datalines;
AB00046,Ronald Baron,0
AB00046,Bill F. Baron,0
AB00046,Tim S.,0
AB00050,Sharon,1
AB00050,Tim S.,0
;
run;


proc sort data=dataset2;
by id;
run;

data cntlin;
set dataset2;
by id;
fmtname = strip(id) !! '_';
type = 'C';
start = name_manager;
label = put(gender,best.);
output;
if last.id
then do;
  name_manager = 'other';
  hlo = 'O';
  label = '';
  output;
end;
drop id name_manager gender;
run;

proc format cntlin=cntlin;
run;

data want;
set dataset1;
array manager {*} manager:;
do i = 1 to dim(manager);
  manager {i} = putc(manager{i},strip(id) !! '_');
end;
drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The appended underline is necessary because your ID values end with numbers. Similarly, you would neet to prepend an underline or a character if ID started with a digit.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 07:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-observations-of-one-dataset-with-the-values-of-another/m-p/525987#M143158</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-10T07:42:19Z</dc:date>
    </item>
  </channel>
</rss>

