<?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 summarizing attributes in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Help-summarizing-attributes/m-p/37082#M9400</link>
    <description>Dear Melissa,&lt;BR /&gt;
&lt;BR /&gt;
try this:&lt;BR /&gt;
&lt;BR /&gt;
data work.myfile;&lt;BR /&gt;
  set work.originalfile;&lt;BR /&gt;
  if product = beer then beer = 1;&lt;BR /&gt;
  else beer = 0;&lt;BR /&gt;
  if product = diapers then diapers = 1;&lt;BR /&gt;
  else diapers = 0;&lt;BR /&gt;
  if product = pencils then pencils = 1;&lt;BR /&gt;
  else pencils = 0;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc summary nway missing;&lt;BR /&gt;
  var beer diapers pencils;&lt;BR /&gt;
  class id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Best regards,&lt;BR /&gt;
Eva</description>
    <pubDate>Fri, 08 Jan 2010 15:51:56 GMT</pubDate>
    <dc:creator>Eva</dc:creator>
    <dc:date>2010-01-08T15:51:56Z</dc:date>
    <item>
      <title>Help summarizing attributes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-summarizing-attributes/m-p/37081#M9399</link>
      <description>[Sorry for double post, not sure if best here or in Data Step forum]&lt;BR /&gt;
&lt;BR /&gt;
Hello, I have a data set with two sorts of “attributes” (probably not using term in strict database sense).&lt;BR /&gt;
&lt;BR /&gt;
I have a perminant attribute of the unique identifier (for example gender). I have multiple records per identifier which describe a transaction (like an item purchased).&lt;BR /&gt;
&lt;BR /&gt;
“ID” – unique identifier&lt;BR /&gt;
“Sex” – gender of ID person&lt;BR /&gt;
“Product” – what was purchased (beer, diapers, pencils)&lt;BR /&gt;
Purch_dt – date of purchase&lt;BR /&gt;
&lt;BR /&gt;
1234 F beer Nov 1, 2008&lt;BR /&gt;
1234 F diapers Nov 24, 2008&lt;BR /&gt;
5678 M beer Nov 17, 2008&lt;BR /&gt;
5678 M pencils Nov 30, 2008&lt;BR /&gt;
&lt;BR /&gt;
I want to &lt;BR /&gt;
- count the number of people who purchased both beer and diapers&lt;BR /&gt;
- count the number of people who purchased beer and no diapers&lt;BR /&gt;
- determine the number of women who purchased beer and diapers&lt;BR /&gt;
- for those who purchased both, determine the time lag between the purchase of beer and diapers&lt;BR /&gt;
&lt;BR /&gt;
I have not written successful code but had two different thoughts (but am willing to do anything that will work). &lt;BR /&gt;
&lt;BR /&gt;
I tried proc SQL “group by ID” but my instinct in English would to say … by ID where Product = beer and Product = diapers but I do not believe this is correct.&lt;BR /&gt;
&lt;BR /&gt;
I tried a do loop by ID and flag if Product = beer and if Product = diapers then do, by unique IDs count flags but this was cumbersome and while the code did something I am not sure it was correct.</description>
      <pubDate>Tue, 05 Jan 2010 20:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-summarizing-attributes/m-p/37081#M9399</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-05T20:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help summarizing attributes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-summarizing-attributes/m-p/37082#M9400</link>
      <description>Dear Melissa,&lt;BR /&gt;
&lt;BR /&gt;
try this:&lt;BR /&gt;
&lt;BR /&gt;
data work.myfile;&lt;BR /&gt;
  set work.originalfile;&lt;BR /&gt;
  if product = beer then beer = 1;&lt;BR /&gt;
  else beer = 0;&lt;BR /&gt;
  if product = diapers then diapers = 1;&lt;BR /&gt;
  else diapers = 0;&lt;BR /&gt;
  if product = pencils then pencils = 1;&lt;BR /&gt;
  else pencils = 0;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc summary nway missing;&lt;BR /&gt;
  var beer diapers pencils;&lt;BR /&gt;
  class id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Best regards,&lt;BR /&gt;
Eva</description>
      <pubDate>Fri, 08 Jan 2010 15:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-summarizing-attributes/m-p/37082#M9400</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2010-01-08T15:51:56Z</dc:date>
    </item>
  </channel>
</rss>

