<?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: duplicate observations - how to transform the them to unique observations? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13570#M2014</link>
    <description>Hi.&lt;BR /&gt;
Your words are ambiguous. Or I can not understand what your mean totally.&lt;BR /&gt;
What output you want to look like?&lt;BR /&gt;
And How to  define the duplicated obs (give an example will be very helpful),&lt;BR /&gt;
What do you do with these duplicated obs?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Mon, 21 Feb 2011 02:43:21 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-02-21T02:43:21Z</dc:date>
    <item>
      <title>duplicate observations - how to transform the them to unique observations?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13566#M2010</link>
      <description>Hi,&lt;BR /&gt;
I am a SAS beginner.&lt;BR /&gt;
My dataset with 4,000 observations looks like this&lt;BR /&gt;
id                startyear     endyear        exposure1       exposure 2       exposure 3&lt;BR /&gt;
id1                1985           1987                            1                    0                     0&lt;BR /&gt;
id2                1992           1997                           1                    0                      0&lt;BR /&gt;
id2                1998            1999                          0                    1                      0&lt;BR /&gt;
id2                 2000           2007                         0                     0                     1&lt;BR /&gt;
id3                 1996           2007                         0                    0                      1&lt;BR /&gt;
id4                 1987           2008                         1                     0                       1&lt;BR /&gt;
&lt;BR /&gt;
The ids are duplicated if the id (person) has reported different time periods for exposures.&lt;BR /&gt;
I need to calculate the cumulative exposure, and I need the ids unique, but keeping the exposure information (to be able to sum them). How can I transform the data so that different exposures in different time periods become variables instead of different observations?&lt;BR /&gt;
(Maybe the columns looks weird, but the 1 and 0 are supposed to be under the column headings "exposure1.. etc")&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Maxi74</description>
      <pubDate>Sat, 19 Feb 2011 18:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13566#M2010</guid>
      <dc:creator>Maxi74</dc:creator>
      <dc:date>2011-02-19T18:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: duplicate observations - how to transform the them to unique observations?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13567#M2011</link>
      <description>Look at using PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
proc transpose site:sas.com</description>
      <pubDate>Sat, 19 Feb 2011 20:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13567#M2011</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-02-19T20:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: duplicate observations - how to transform the them to unique observations?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13568#M2012</link>
      <description>hi Maxi74 &lt;BR /&gt;
 other way of the solution:&lt;BR /&gt;
data x;&lt;BR /&gt;
input id $ startyear endyear exposure1 exposure2 exposure3 ;&lt;BR /&gt;
cards;&lt;BR /&gt;
id1 1985 1987 1 0 0&lt;BR /&gt;
id2 1992 1997 1 0 0&lt;BR /&gt;
id2 1998 1999 0 1 0&lt;BR /&gt;
id2 2000 2007 0 0 1&lt;BR /&gt;
id3 1996 2007 0 0 1&lt;BR /&gt;
id4 1987 2008 1 0 1&lt;BR /&gt;
;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
data x ;&lt;BR /&gt;
set x ;&lt;BR /&gt;
 new_id=substr(compress(id),1,2) ;&lt;BR /&gt;
proc sort ; by new_id ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
data res ;&lt;BR /&gt;
set x ;&lt;BR /&gt;
 by new_id ;&lt;BR /&gt;
   if first.new_id then sum=exposure1;&lt;BR /&gt;
   else sum+exposure1;&lt;BR /&gt;
   if last.new_id then output;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Irena</description>
      <pubDate>Sun, 20 Feb 2011 07:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13568#M2012</guid>
      <dc:creator>ariari</dc:creator>
      <dc:date>2011-02-20T07:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: duplicate observations - how to transform the them to unique observations?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13569#M2013</link>
      <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
if your goal is to get a report with total exposures per id you can try the report procedure (which will also can create a data set):&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data x;&lt;BR /&gt;
input id $ startyear endyear exposure1 exposure2 exposure3 ;&lt;BR /&gt;
cards;&lt;BR /&gt;
id1 1985 1987 1 0 0&lt;BR /&gt;
id2 1992 1997 1 1 0&lt;BR /&gt;
id2 1998 1999 0 1 0&lt;BR /&gt;
id2 2000 2007 0 0 1&lt;BR /&gt;
id3 1996 2007 0 0 1&lt;BR /&gt;
id4 1987 2008 1 0 1&lt;BR /&gt;
;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=x out=in_case nowd;&lt;BR /&gt;
column id exposure1 exposure2 exposure3 total;&lt;BR /&gt;
define id / group;&lt;BR /&gt;
compute total;&lt;BR /&gt;
	total=sum (exposure1.sum,exposure2.sum,exposure3.sum);&lt;BR /&gt;
endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Sun, 20 Feb 2011 16:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13569#M2013</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-20T16:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: duplicate observations - how to transform the them to unique observations?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13570#M2014</link>
      <description>Hi.&lt;BR /&gt;
Your words are ambiguous. Or I can not understand what your mean totally.&lt;BR /&gt;
What output you want to look like?&lt;BR /&gt;
And How to  define the duplicated obs (give an example will be very helpful),&lt;BR /&gt;
What do you do with these duplicated obs?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 21 Feb 2011 02:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/duplicate-observations-how-to-transform-the-them-to-unique/m-p/13570#M2014</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-02-21T02:43:21Z</dc:date>
    </item>
  </channel>
</rss>

