<?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: Help with data manipulation in data step in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123302#M33885</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I may be mis-reading your question and if so, I apologize. But it sounds like you can have a dataset (healthy) with variables&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (school, student, date-attended) and another dataset (infected) with variables (school,infected-student,date-attended) then do a merge:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=healthy; by school date-attended;&lt;/P&gt;&lt;P&gt;proc sort data=infected; by school date-attended;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data mergem;&lt;/P&gt;&lt;P&gt;set healthy; by school date-attended;&lt;/P&gt;&lt;P&gt;set infected; by school date-attended;&lt;/P&gt;&lt;P&gt;merge healthy (in=inh) infected (in=inf);&lt;/P&gt;&lt;P&gt;if inh and inf then output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=mergem; by student infected-student;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=mergem; tables student*infected-student;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that would give you a table by healthy-student and each infected-student with the # of potential interactions for each combination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Apr 2013 18:47:24 GMT</pubDate>
    <dc:creator>lloydc</dc:creator>
    <dc:date>2013-04-28T18:47:24Z</dc:date>
    <item>
      <title>Help with data manipulation in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123301#M33884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to link records in my data by whether a few conditions apply. I want to create a new variable to determine contact with an infected classmate. I have my data so that for every day a student is in a particular school there is a separate record. I want to create a new variable "contact" that indicates whether a student was at the same school on the same day as any of the infected students (does not matter if it was one infected student or 10). I also need a way to prevent it saying it was in contact with an infected student if the infected student was himself (I hope that makes sense). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Apr 2013 18:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123301#M33884</guid>
      <dc:creator>LucyLou</dc:creator>
      <dc:date>2013-04-28T18:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help with data manipulation in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123302#M33885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I may be mis-reading your question and if so, I apologize. But it sounds like you can have a dataset (healthy) with variables&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (school, student, date-attended) and another dataset (infected) with variables (school,infected-student,date-attended) then do a merge:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=healthy; by school date-attended;&lt;/P&gt;&lt;P&gt;proc sort data=infected; by school date-attended;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data mergem;&lt;/P&gt;&lt;P&gt;set healthy; by school date-attended;&lt;/P&gt;&lt;P&gt;set infected; by school date-attended;&lt;/P&gt;&lt;P&gt;merge healthy (in=inh) infected (in=inf);&lt;/P&gt;&lt;P&gt;if inh and inf then output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=mergem; by student infected-student;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=mergem; tables student*infected-student;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that would give you a table by healthy-student and each infected-student with the # of potential interactions for each combination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Apr 2013 18:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123302#M33885</guid>
      <dc:creator>lloydc</dc:creator>
      <dc:date>2013-04-28T18:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with data manipulation in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123303#M33886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will make a slightly different guess about your data structure and assume you have a single dataset with variables School, Student, Date, and Contagious. The following query would give you useful information (untested) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;create table contact as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.school, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.student, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coalesce(count(distinct B.student), 0) as nbStudents,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min(B.date) as firstContact format=date9., &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(B.date) as lastContact format=date9.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;from &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from attendance where not contagious) as A left join &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from attendance where contagious) as B&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG style="font-size: 12pt;"&gt;on A.school=B.school and A.date=B.date and A.student ne B.student&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;group by A.school, A.student;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Apr 2013 19:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123303#M33886</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-04-28T19:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with data manipulation in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123304#M33887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this worked! Thank you so much. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Apr 2013 03:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-data-manipulation-in-data-step/m-p/123304#M33887</guid>
      <dc:creator>LucyLou</dc:creator>
      <dc:date>2013-04-29T03:52:27Z</dc:date>
    </item>
  </channel>
</rss>

