<?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 to populate a group of variables with the non missing value for all the group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743068#M232556</link>
    <description>&lt;P&gt;Why is the output for group 2 a zero when there was one non-missing in the input?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Don't type in a code box if you are not going to show us code.&lt;/P&gt;</description>
    <pubDate>Fri, 21 May 2021 22:20:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-05-21T22:20:23Z</dc:date>
    <item>
      <title>How to populate a group of variables with the non missing value for all the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743066#M232555</link>
      <description>&lt;LI-CODE lang="sas"&gt;Input data:

group flag
1 . 
1 . 
1 1 
1 .
2 . 
2 1 
2 . 
3 .
3 1
3 .
3 1
3 .
3 .
;

I want the following output
so for every group, if there is a flag=1 then all the flag_new should be a 1 for everyone in that group. If missing then all the values should be 0

Output desired:

group flag new_flag
1 . 1
1 . 1
1 1 1
1 . 1
2 . 0
2 . 0
2 . 0
3 . 1
3 1 1
3 . 1
3 1 1
3 . 1
3 . 1&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 May 2021 22:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743066#M232555</guid>
      <dc:creator>sbopster</dc:creator>
      <dc:date>2021-05-21T22:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a group of variables with the non missing value for all the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743068#M232556</link>
      <description>&lt;P&gt;Why is the output for group 2 a zero when there was one non-missing in the input?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Don't type in a code box if you are not going to show us code.&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 22:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743068#M232556</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-21T22:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a group of variables with the non missing value for all the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743074#M232560</link>
      <description>&lt;P&gt;if I knew how to do it or had code I would type it in. I mean how else are you supposed to ask a question? thank you for your response.&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 22:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743074#M232560</guid>
      <dc:creator>sbopster</dc:creator>
      <dc:date>2021-05-21T22:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a group of variables with the non missing value for all the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743076#M232561</link>
      <description>&lt;P&gt;You just did it. You typed your comment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why does group 2 have a zero in the output but a non-missing in the input?&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 22:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743076#M232561</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-21T22:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a group of variables with the non missing value for all the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743093#M232568</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have   have (keep=group flag where=(flag^=.));
  by group;
  if  flag=. then flag=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works&amp;nbsp; as expected if (1) data are sorted by group, (2) no group has any variation in non-missing values&amp;nbsp; of flag.&lt;/P&gt;</description>
      <pubDate>Sat, 22 May 2021 01:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743093#M232568</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-05-22T01:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a group of variables with the non missing value for all the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743123#M232582</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group flag;
cards;
1 . 
1 . 
1 1 
1 .
2 . 
2 . 
2 . 
3 .
3 1
3 .
3 1
3 .
3 .
;

proc sql;
create table want as
select *,max(flag)=1 as new_flag
 from have 
  group by group;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 May 2021 11:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-populate-a-group-of-variables-with-the-non-missing-value/m-p/743123#M232582</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-22T11:43:07Z</dc:date>
    </item>
  </channel>
</rss>

