<?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 flagging dups on multiple vars in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20778#M4319</link>
    <description>Hello, &lt;BR /&gt;
I'm in the early days of converting from SPSS to SAS.&lt;BR /&gt;
&lt;BR /&gt;
My file has the first four columns.  I want to add the last two columns--LAST and COUNT.&lt;BR /&gt;
&lt;BR /&gt;
LAST indicates if a record is unique  based on  id, v2, and flag.&lt;BR /&gt;
COUNT would be a cumulative count based on id and v2 ordered by date where 0 means unique record.&lt;BR /&gt;
&lt;BR /&gt;
id	      v2     flag	date	        LAST COUNT&lt;BR /&gt;
1,	        a,	0,	1/1/2008,	  1,        1&lt;BR /&gt;
1,	        a,	1,	1/7/2009,	  1,	     2&lt;BR /&gt;
1,	        b,	1,	1/1/2009,	  1,	     0&lt;BR /&gt;
1,	        c,	0,	1/1/2007,	  0,	     1&lt;BR /&gt;
1,	        c,	0,	1/1/2008,	  1,	     2&lt;BR /&gt;
1,	        c,	1,	1/1/2009,	  1,	     3&lt;BR /&gt;
1,	        d,	0,	6/1/2007,	  1,	     0&lt;BR /&gt;
&lt;BR /&gt;
I'm totally stumped on how to create last.  I think I've figured out a really inelegant way to get the count var, but an easier way would be appreciated. &lt;BR /&gt;
&lt;BR /&gt;
Thanks for any help!&lt;BR /&gt;
&lt;BR /&gt;
Dana</description>
    <pubDate>Fri, 17 Apr 2009 17:17:44 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-04-17T17:17:44Z</dc:date>
    <item>
      <title>flagging dups on multiple vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20778#M4319</link>
      <description>Hello, &lt;BR /&gt;
I'm in the early days of converting from SPSS to SAS.&lt;BR /&gt;
&lt;BR /&gt;
My file has the first four columns.  I want to add the last two columns--LAST and COUNT.&lt;BR /&gt;
&lt;BR /&gt;
LAST indicates if a record is unique  based on  id, v2, and flag.&lt;BR /&gt;
COUNT would be a cumulative count based on id and v2 ordered by date where 0 means unique record.&lt;BR /&gt;
&lt;BR /&gt;
id	      v2     flag	date	        LAST COUNT&lt;BR /&gt;
1,	        a,	0,	1/1/2008,	  1,        1&lt;BR /&gt;
1,	        a,	1,	1/7/2009,	  1,	     2&lt;BR /&gt;
1,	        b,	1,	1/1/2009,	  1,	     0&lt;BR /&gt;
1,	        c,	0,	1/1/2007,	  0,	     1&lt;BR /&gt;
1,	        c,	0,	1/1/2008,	  1,	     2&lt;BR /&gt;
1,	        c,	1,	1/1/2009,	  1,	     3&lt;BR /&gt;
1,	        d,	0,	6/1/2007,	  1,	     0&lt;BR /&gt;
&lt;BR /&gt;
I'm totally stumped on how to create last.  I think I've figured out a really inelegant way to get the count var, but an easier way would be appreciated. &lt;BR /&gt;
&lt;BR /&gt;
Thanks for any help!&lt;BR /&gt;
&lt;BR /&gt;
Dana</description>
      <pubDate>Fri, 17 Apr 2009 17:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20778#M4319</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-17T17:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: flagging dups on multiple vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20779#M4320</link>
      <description>The SAS DATA step and using FIRST.&lt;VARNAME&gt; and LAST.&lt;VARNAME&gt;  against your sorted file, and specifying the required BY statement with your variable list.  The SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website has DOC and supplemental technical papers.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
How the DATA Step Identifies BY Groups&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000761931.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000761931.htm&lt;/A&gt;&lt;/VARNAME&gt;&lt;/VARNAME&gt;</description>
      <pubDate>Fri, 17 Apr 2009 17:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20779#M4320</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-17T17:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: flagging dups on multiple vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20780#M4321</link>
      <description>Hello lockwoo,&lt;BR /&gt;
&lt;BR /&gt;
Could this help? &lt;BR /&gt;
&lt;BR /&gt;
yoba&lt;BR /&gt;
&lt;BR /&gt;
data T01_input;&lt;BR /&gt;
length v2 $1;&lt;BR /&gt;
infile cards delimiter=',' firstobs=2;&lt;BR /&gt;
input id v2 flag date last count;&lt;BR /&gt;
informat date ddmmyy10.; format date date9.;&lt;BR /&gt;
cards;&lt;BR /&gt;
id, v2, flag, date, LAST, COUNT&lt;BR /&gt;
1, a, 0, 1/1/2008, 1, 1&lt;BR /&gt;
1, a, 1, 1/7/2009, 1, 2&lt;BR /&gt;
1, b, 1, 1/1/2009, 1, 0&lt;BR /&gt;
1, c, 0, 1/1/2007, 0, 1&lt;BR /&gt;
1, c, 0, 1/1/2008, 1, 2&lt;BR /&gt;
1, c, 1, 1/1/2009, 1, 3&lt;BR /&gt;
1, d, 0, 6/1/2007, 1, 0&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=T01_input;&lt;BR /&gt;
by id v2 flag;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data T02_temp;&lt;BR /&gt;
set T01_input;&lt;BR /&gt;
by id v2 flag;&lt;BR /&gt;
if first.flag=last.flag=1 then LAST2=1; else LAST2=0;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=T02_temp;&lt;BR /&gt;
by id v2 date;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data T03_output;&lt;BR /&gt;
set T02_temp;&lt;BR /&gt;
by id v2 date;&lt;BR /&gt;
if first.V2 then COUNT2=0;&lt;BR /&gt;
if not (first.V2=last.V2=1) then COUNT2+1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=T03_output;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 17 Apr 2009 18:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20780#M4321</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-17T18:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: flagging dups on multiple vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20781#M4322</link>
      <description>Terrific!  I knew it had to be easier than I was making it.&lt;BR /&gt;
Thank you thank you&lt;BR /&gt;
&lt;BR /&gt;
Dana</description>
      <pubDate>Fri, 17 Apr 2009 18:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-dups-on-multiple-vars/m-p/20781#M4322</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-17T18:57:58Z</dc:date>
    </item>
  </channel>
</rss>

