<?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: creating a dummy dependent on lagged values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576274#M13038</link>
    <description>&lt;P&gt;Thanks, Ksharp! Your solution works too!&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2019 17:24:12 GMT</pubDate>
    <dc:creator>AmirSari</dc:creator>
    <dc:date>2019-07-24T17:24:12Z</dc:date>
    <item>
      <title>creating a dummy dependent on lagged values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576051#M12983</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample of my dataset. I want to create a dummy variable for the auditor’s first time audit with the client&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Client_id year auditor_id dummy&lt;BR /&gt;1 1990 6 1&lt;BR /&gt;1 1991 6 0&lt;BR /&gt;1 1992 4 1&lt;BR /&gt;1 1993 4 0&lt;BR /&gt;1 1994 8 1&lt;BR /&gt;1 1995 8 0&lt;BR /&gt;1 1996 4 0&lt;BR /&gt;1 1997 4 0&lt;BR /&gt;2 1990 5 1&lt;BR /&gt;2 1991 5 0&lt;BR /&gt;2 1992 5 0&lt;BR /&gt;2 1993 5 0&lt;BR /&gt;2 1994 5 0&lt;BR /&gt;2 1995 5 0 &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dummy takes 1 for the first observation of each Client_id . For other observations dummy takes 1 only if it is the auditor’s first time audit with the client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help! &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 07:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576051#M12983</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2019-07-24T07:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating a dummy dependent on lagged values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576054#M12984</link>
      <description>It's easy if you sort your data:&lt;BR /&gt;&lt;BR /&gt;proc sort data=have;&lt;BR /&gt;by client_id auditor_ud year;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by client_id auditor_id;&lt;BR /&gt;dummy = first.auditor_id;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;If you want to, sort your data again to put it back in its original order.</description>
      <pubDate>Wed, 24 Jul 2019 07:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576054#M12984</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-07-24T07:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: creating a dummy dependent on lagged values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576111#M13008</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Client_id year auditor_id dummy	;
cards;
1 1990 6 1
1 1991 6 0
1 1992 4 1
1 1993 4 0
1 1994 8 1
1 1995 8 0
1 1996 4 0
1 1997 4 0
2 1990 5 1
2 1991 5 0
2 1992 5 0
2 1993 5 0
2 1994 5 0
2 1995 5 0  
;
data want;
 if _n_=1 then do;
  if 0 then set have;
  declare hash h();
  h.definekey('auditor_id');
  h.definedone();
 end;
set have;
by Client_id;
if first.Client_id then h.clear();
if h.check()=0 then want=0;
 else do;want=1; h.add();end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 11:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576111#M13008</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-24T11:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: creating a dummy dependent on lagged values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576274#M13038</link>
      <description>&lt;P&gt;Thanks, Ksharp! Your solution works too!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 17:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576274#M13038</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2019-07-24T17:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: creating a dummy dependent on lagged values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576275#M13039</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 17:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/creating-a-dummy-dependent-on-lagged-values/m-p/576275#M13039</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2019-07-24T17:24:42Z</dc:date>
    </item>
  </channel>
</rss>

