<?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: Create dummy variable for group in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/225156#M53904</link>
    <description>&lt;P&gt;Hi, just a small variation on an already posted solution ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;data want;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;want = 0;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;do until (last.id);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;set have (in=one) have;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;by id;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;if one and have then want = 1;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;if ^one then output;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;It's based on Howard Schreier's idea of a "self-interleave" ...&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;Interleaving a Dataset with Itself: How and Why&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;A href="http://www.lexjansen.com/nesug/nesug03/cc/cc002.pdf" target="_blank"&gt;http://www.lexjansen.com/nesug/nesug03/cc/cc002.pdf&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2015 13:20:34 GMT</pubDate>
    <dc:creator>MikeZdeb</dc:creator>
    <dc:date>2015-09-11T13:20:34Z</dc:date>
    <item>
      <title>Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209310#M51870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Hi,&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I am trying to create the dummy variable &lt;EM&gt;Want &lt;/EM&gt;which is = 1 if there is any observation that has a value in &lt;EM&gt;Have&lt;/EM&gt;.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;E.g. &lt;EM&gt;Want&lt;/EM&gt; = 1 for all observations of A1 because there is at least one observation with a value in &lt;EM&gt;Have&lt;/EM&gt;. &lt;EM&gt;Want&lt;/EM&gt; = 0 for B1.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Is there a way to code this? Thanks for your help! &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Sample data:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 192px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;ID&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit; text-align: center;" width="64"&gt;Have&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit; text-align: center;" width="64"&gt;Want&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;100&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;A1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="font-style: inherit; text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="font-style: inherit; text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" style="font-style: inherit; text-align: center;" width="64"&gt;B1&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;.&lt;/TD&gt;&lt;TD class="xl64" style="text-align: center;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Regards,&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 07:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209310#M51870</guid>
      <dc:creator>sasvader</dc:creator>
      <dc:date>2015-08-28T07:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209311#M51871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without writing code, I'm not sure, but how about something like using PROC MEANS (or SUMMARY) to get the max value for 'Have" for each level of ID.&amp;nbsp; Then create 'Want' in the output dataset (something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if maxval&amp;gt;. then want=1 else want=0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then finally merging back on the original dataset with ID as the key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will wager a nearly infinite sum of money that there is a PROC SQL approach that would do this as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 11:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209311#M51871</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2015-08-28T11:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209312#M51872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case when exists(select distinct ID from HAVE where ID=A.ID and HAVE is not null) then 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else 0 end as WANT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE A;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I accept Paypal SteveDenham &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 12:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209312#M51872</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-08-28T12:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209313#M51873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, but my wager was that there WAS a simple way to do this in PROC SQL.&amp;nbsp; I too accept PayPal...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 12:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209313#M51873</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2015-08-28T12:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209314#M51874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H3 style="color: #353535; font-family: Lato, sans-serif; background-color: #f0f1f2;"&gt;Code: Program&lt;/H3&gt;&lt;PRE class="sce-render" style="font-family: 'Courier New', Menlo, 'Lucida Console'; font-size: 16px;"&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;data&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;have&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;infile&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;expandtabs&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;input&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;$&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;Have&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 100 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;A1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="cards-data" style="color: #bb9905;"&gt;B1 . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;data&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;want&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;merge&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;have&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;have&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;Have&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;H&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;where&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;H&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;is&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;not&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;in&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;inb&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;by&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;want&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;inb&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;drop&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;H&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 12:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209314#M51874</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-08-28T12:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209315#M51875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, Steve, You are already rich enough &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select *, sum(not missing(have))&amp;gt;0 as want &lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;group by id;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 13:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209315#M51875</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-08-28T13:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209316#M51876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Besides @xia keshan 's Merge, there are also many other data step approach, a classic 2XDOW would be one, a verbose Hash, or such as the following stacking approach:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards expandtabs;&lt;/P&gt;&lt;P&gt;input ID $ Have;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;A1 .&lt;/P&gt;&lt;P&gt;A1 . &lt;/P&gt;&lt;P&gt;A1 100 &lt;/P&gt;&lt;P&gt;A1 . &lt;/P&gt;&lt;P&gt;A1 . &lt;/P&gt;&lt;P&gt;A1 . &lt;/P&gt;&lt;P&gt;A1 . &lt;/P&gt;&lt;P&gt;A1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;B1 . &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have(in=up) have(in=down);&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;retain want;&lt;/P&gt;&lt;P&gt;if first.id then want=0;&lt;/P&gt;&lt;P&gt;if not missing(have) then want=1;&lt;/P&gt;&lt;P&gt;if down then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 13:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209316#M51876</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-08-28T13:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209317#M51877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This accomplishes the same using a SAS hash object. Enjoy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; _n_ = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: green; background: white;"&gt;*declare a SAS hash object;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; hash t(dataset: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: purple; background: white;"&gt;'have(where=(have is not missing))'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.definekey(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: purple; background: white;"&gt;'ID'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.definedone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp; Want=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: green; background: white;"&gt;*set initial value;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; T.find()=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt; Want=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: green; background: white;"&gt;*if found, change Want to 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: Consolas; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Aug 2015 19:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/209317#M51877</guid>
      <dc:creator>hbi</dc:creator>
      <dc:date>2015-08-28T19:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variable for group</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/225156#M53904</link>
      <description>&lt;P&gt;Hi, just a small variation on an already posted solution ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;data want;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;want = 0;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;do until (last.id);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;set have (in=one) have;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;by id;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;if one and have then want = 1;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;if ^one then output;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;It's based on Howard Schreier's idea of a "self-interleave" ...&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;Interleaving a Dataset with Itself: How and Why&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;A href="http://www.lexjansen.com/nesug/nesug03/cc/cc002.pdf" target="_blank"&gt;http://www.lexjansen.com/nesug/nesug03/cc/cc002.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 13:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variable-for-group/m-p/225156#M53904</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-09-11T13:20:34Z</dc:date>
    </item>
  </channel>
</rss>

