<?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: Assign the same value by group of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870519#M343817</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
infile datalines dlm=',' dsd;
input ID_A $ ID_B $ var1 $ var2 $ var3 $;
datalines;
ID 00, ID 10, ,Y,
ID 00, ID 10, , ,
ID 00, ID 20,Y, ,
ID 00, ID 20, , ,
ID 01, ID 10,Y, ,Y
ID 01, ID 10, , ,
ID 01, ID 20, ,Y,
ID 01, ID 20, , ,
;


data want;
   do until (last.ID_B);
      update have2(obs=0) have2;
      by ID_A ID_B;
   end;
   do until (last.ID_B);
      set have2 (keep=ID_A ID_B);  
      by ID_A ID_B;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Apr 2023 10:58:43 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2023-04-19T10:58:43Z</dc:date>
    <item>
      <title>Assign the same value by group of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870516#M343815</link>
      <description>&lt;P&gt;I have this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dlm=',' dsd;
input ID $ var1 $ var2 $ var3 $;
datalines;
ID 00, ,Y,
ID 00, , ,
ID 00,Y, ,
ID 01,Y, ,Y
ID 01, , ,
;
data want;
do until (last.id);
update have(obs=0) have;
by ID;
end;
do until (last.id);
set have (keep=id);   by id;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got this code here:&lt;/P&gt;
&lt;P&gt;&lt;A title="Assign the same variable by group" href="https://communities.sas.com/t5/SAS-Programming/assign-the-same-value-by-group/td-p/717919" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/assign-the-same-value-by-group/td-p/717919&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Instead of grouping by one variable I want to group by two or more variables. How can I adapt the code to this dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
infile datalines dlm=',' dsd;
input ID_A $ ID_B $ var1 $ var2 $ var3 $;
datalines;
ID 00, ID 10, ,Y,
ID 00, ID 10, , ,
ID 00, ID 20,Y, ,
ID 00, ID 20, , ,
ID 01, ID 10,Y, ,Y
ID 01, ID 10, , ,
ID 01, ID 20, ,Y,
ID 01, ID 20, , ,
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2023 10:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870516#M343815</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2023-04-19T10:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assign the same value by group of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870519#M343817</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
infile datalines dlm=',' dsd;
input ID_A $ ID_B $ var1 $ var2 $ var3 $;
datalines;
ID 00, ID 10, ,Y,
ID 00, ID 10, , ,
ID 00, ID 20,Y, ,
ID 00, ID 20, , ,
ID 01, ID 10,Y, ,Y
ID 01, ID 10, , ,
ID 01, ID 20, ,Y,
ID 01, ID 20, , ,
;


data want;
   do until (last.ID_B);
      update have2(obs=0) have2;
      by ID_A ID_B;
   end;
   do until (last.ID_B);
      set have2 (keep=ID_A ID_B);  
      by ID_A ID_B;
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2023 10:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870519#M343817</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-04-19T10:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Assign the same value by group of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870525#M343821</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if I want do do this only for var2 instead of var1, var2, and var3?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 11:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870525#M343821</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2023-04-19T11:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Assign the same value by group of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870726#M343930</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/369095"&gt;@ramgouveia&lt;/a&gt;&amp;nbsp;Sorry for the late reply. Did you find your answer?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 08:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870726#M343930</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-04-20T08:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Assign the same value by group of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870749#M343938</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This one solved my problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="Filling empty cells with other cells of the same column" href="https://communities.sas.com/t5/SAS-Programming/Filling-empty-cell-with-others-cells-of-the-same-column/td-p/758538" target="_self"&gt;Filling empty cells with other cells of the same column&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 11:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-same-value-by-group-of-variables/m-p/870749#M343938</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2023-04-20T11:13:25Z</dc:date>
    </item>
  </channel>
</rss>

