<?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: creation of dummy with multiple observations in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621888#M19676</link>
    <description>data want;&lt;BR /&gt;set have;&lt;BR /&gt;by firmID;&lt;BR /&gt;if first.firmID or audit_year &amp;gt; . then wanted = audit_year;&lt;BR /&gt;dummy = year = wanted &amp;gt; . ;&lt;BR /&gt;drop wanted;&lt;BR /&gt;retain wanted;&lt;BR /&gt;run;</description>
    <pubDate>Mon, 03 Feb 2020 08:32:39 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-02-03T08:32:39Z</dc:date>
    <item>
      <title>creation of dummy with multiple observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621867#M19672</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I am trying to create a dummy where the year is equal to the audit year. There are multiple observations for a particular firm.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-undefined"&gt;&lt;CODE class="yiv3189631474 yiv3189631474language-sas language-undefined"&gt;Firm ID  Year    Audit_year        Dummy (what I want)&lt;BR /&gt;11      1990       .                   0
11      1991       .                   0 
11      1992   1993                    0&lt;BR /&gt;11      1993       .                   1
11      1993       .                   1&lt;BR /&gt;11      1993       .                   1
11      1994   1995                    0
11      1995       .                   1  
11      1996       .                   0
12      2001       .                   0
12      2002   2003                    0
12      2003      .                    1
12      2004      .                    0
12     2005       .                    0
12     2006       .                    0
12     2007       .                    0
12     2008       .                    0
12     2009       .                    0&lt;BR /&gt;&lt;BR /&gt;In&amp;nbsp;the&amp;nbsp;latter&amp;nbsp;table,&amp;nbsp;audit&amp;nbsp;years&amp;nbsp;are&amp;nbsp;one&amp;nbsp;year&amp;nbsp;ahead&amp;nbsp;of&amp;nbsp;YEAR.&amp;nbsp;Please&amp;nbsp;help&amp;nbsp;with&amp;nbsp;respect&amp;nbsp;to&amp;nbsp;the&amp;nbsp;codes&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Amanjot&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 05:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621867#M19672</guid>
      <dc:creator>amanjot_42</dc:creator>
      <dc:date>2020-02-03T05:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: creation of dummy with multiple observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621870#M19673</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input FirmID Year Audit_year;
datalines;
11 1990 .
11 1991 .
11 1992 1993
11 1993 .
11 1993 .
11 1993 .
11 1994 1995
11 1995 . 
11 1996 .
12 2001 .
12 2002 2003
12 2003 .
12 2004 .
12 2005 .
12 2006 .
12 2007 .
12 2008 .
12 2009 .
;

data want(drop=_:);
   merge have
         have (firstobs=2 keep=FirmID Year rename=(FirmID=_FirmID Year=_Year));
   dummy = FirmID = _FirmID &amp;amp; Audit_year = _Year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;FirmID Year  Audit_year dummy 
11     1990  .          0 
11     1991  .          0 
11     1992  1993       1 
11     1993  .          0 
11     1993  .          0 
11     1993  .          0 
11     1994  1995       1 
11     1995  .          0 
11     1996  .          0 
12     2001  .          0 
12     2002  2003       1 
12     2003  .          0 
12     2004  .          0 
12     2005  .          0 
12     2006  .          0 
12     2007  .          0 
12     2008  .          0 
12     2009  .          0 &lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 05:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621870#M19673</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-03T05:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: creation of dummy with multiple observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621887#M19675</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/198822"&gt;@amanjot_42&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an attempt to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop = _Audit_year);
	set have;
	if Audit_year ne . then _Audit_year=0;
	_Audit_year + Audit_year;
	if _Audit_year = Year then Dummy = 1;
	else Dummy = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Output" style="width: 205px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35814i933BA0852F570BF4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-02-03 à 09.24.51.png" alt="Output" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Output&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 08:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621887#M19675</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-03T08:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: creation of dummy with multiple observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621888#M19676</link>
      <description>data want;&lt;BR /&gt;set have;&lt;BR /&gt;by firmID;&lt;BR /&gt;if first.firmID or audit_year &amp;gt; . then wanted = audit_year;&lt;BR /&gt;dummy = year = wanted &amp;gt; . ;&lt;BR /&gt;drop wanted;&lt;BR /&gt;retain wanted;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 03 Feb 2020 08:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creation-of-dummy-with-multiple-observations/m-p/621888#M19676</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-02-03T08:32:39Z</dc:date>
    </item>
  </channel>
</rss>

