<?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: How to find variable that is present in each time period in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384163#M91689</link>
    <description>&lt;P&gt;Unfortunately the real data&amp;nbsp;&lt;EM&gt;is&amp;nbsp;&lt;/EM&gt;huge, with millions of rows. The date is always a Sunday (not sure if this is something I can work off?) and represents the week starting (so e.g. week starting Sunday 01/01/2017). So let's say that I would like to see how many PERSONs have observations&amp;nbsp;&lt;STRONG&gt;every&amp;nbsp;&lt;/STRONG&gt;Sunday for a particular period (e.g. 50 or 100 weeks).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A PERSON can have multiple entries a given date.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 06:29:50 GMT</pubDate>
    <dc:creator>Ltwo</dc:creator>
    <dc:date>2017-07-31T06:29:50Z</dc:date>
    <item>
      <title>How to find variable that is present in each time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384161#M91687</link>
      <description>&lt;P&gt;Hi SAS experts, I have a dataset that shows something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SASHELP.SAMPLE;
  infile datalines dsd truncover;
  input DATE:DDMMYY10. PERSON:$4. TASK:$4.;
  format DATE date9.;
datalines4;
01/01/2017,1000,AB
01/01/2017,1000,ABC
01/01/2017,1111,ABCD
01/01/2017,1111,ABC
01/01/2017,2111,ABCD
08/01/2017,1000,XY
08/01/2017,2111,ABC
08/01/2017,2111,XYZ
15/01/2017,1000,ABC
15/01/2017,1000,ABCD
15/01/2017,1000,AA
22/01/2017,1111,ABC
22/01/2017,1000,ABC
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I'm basically looking for, is to identify PERSONs that have recorded an observation in each of the 4 dates&amp;nbsp;that I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as we can see from the dataset above, only PERSON="1000" satisfies my requirement. So I want my eventual dataset to only contain PERSONs that meets the requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SASHELP.WANT;
 infile datalines dsd truncover;
  input DATE:DDMMYY10. PERSON:$4. TASK:$4.;
  format DATE date9.;
datalines4;
01/01/2017,1000,AB
01/01/2017,1000,ABC
08/01/2017,1000,XY
15/01/2017,1000,ABC
15/01/2017,1000,ABCD
15/01/2017,1000,AA
22/01/2017,1000,ABC
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 06:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384161#M91687</guid>
      <dc:creator>Ltwo</dc:creator>
      <dc:date>2017-07-31T06:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to find variable that is present in each time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384162#M91688</link>
      <description>If your real data is not huge, I would first query how many dates that you have, and store that as a macro variable (SQL SELECT INTO:...).&lt;BR /&gt;Then the next query with a group by on Person, and having count (date) = &amp;amp;yourmacrovarcreatedinthepreviousstep.&lt;BR /&gt;&lt;BR /&gt;Can a person gave multiple entries for a given date?</description>
      <pubDate>Mon, 31 Jul 2017 06:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384162#M91688</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-07-31T06:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to find variable that is present in each time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384163#M91689</link>
      <description>&lt;P&gt;Unfortunately the real data&amp;nbsp;&lt;EM&gt;is&amp;nbsp;&lt;/EM&gt;huge, with millions of rows. The date is always a Sunday (not sure if this is something I can work off?) and represents the week starting (so e.g. week starting Sunday 01/01/2017). So let's say that I would like to see how many PERSONs have observations&amp;nbsp;&lt;STRONG&gt;every&amp;nbsp;&lt;/STRONG&gt;Sunday for a particular period (e.g. 50 or 100 weeks).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A PERSON can have multiple entries a given date.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 06:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384163#M91689</guid>
      <dc:creator>Ltwo</dc:creator>
      <dc:date>2017-07-31T06:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find variable that is present in each time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384165#M91690</link>
      <description>&lt;P&gt;You can do it in a single SQL step, but be aware that the performance might be bad if your dataset is large:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.*
from sample a
where a.person in (
  select b.person
  from sample b
  group by b.person
  having count(distinct date) &amp;gt;= 4
);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 06:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384165#M91690</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-31T06:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to find variable that is present in each time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384244#M91733</link>
      <description>&lt;PRE&gt;



data SAMPLE;
  infile datalines dsd truncover;
  input DATE:DDMMYY10. PERSON:$4. TASK:$4.;
  format DATE date9.;
datalines4;
01/01/2017,1000,AB
01/01/2017,1000,ABC
01/01/2017,1111,ABCD
01/01/2017,1111,ABC
01/01/2017,2111,ABCD
08/01/2017,1000,XY
08/01/2017,2111,ABC
08/01/2017,2111,XYZ
15/01/2017,1000,ABC
15/01/2017,1000,ABCD
15/01/2017,1000,AA
22/01/2017,1111,ABC
22/01/2017,1000,ABC
;;;;

proc sql;
create table want as
 select *
  from sample
   group by person
    having count(distinct date)=
(select count(distinct date) from sample)
order by person,date;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384244#M91733</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-31T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to find variable that is present in each time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384277#M91743</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you need a subrequest here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	CREATE TABLE want AS
	SELECT *
	FROM SAMPLE
	GROUP BY PERSON
	HAVING count(DISTINCT DATE) ge 4;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-variable-that-is-present-in-each-time-period/m-p/384277#M91743</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-07-31T14:09:40Z</dc:date>
    </item>
  </channel>
</rss>

