<?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: Select first login only per day in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681779#M79470</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266526"&gt;@RALL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to get the login data for users displayed per day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I want the first login only for that user and I want it per day (users log in multiple times per day and so I only want their first login for that day), I have been struggling to get it per day, any help would be much appreciated.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sample data please, in the form of a data step.&amp;nbsp; Followed by the desired result, also in the form of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help us help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note:&amp;nbsp; Let's assume your data are sorted chronologically, so each userid appears scattered throughout the data set.&amp;nbsp; This is a case where the efficiency of hash object shines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if 0 then set have;
  declare hash h (dataset:'have',ordered:'A');
    h.definekey('userid');
    h.definedata(all:'Y');
    h.definedone();
  h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works because:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;By default, the hash object (think lookup table) will keep only one &lt;EM&gt;&lt;STRONG&gt;dataitem&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; (i.e. one record) per key (i.e. per userid).&lt;/LI&gt;
&lt;LI&gt;Also by default, once a given key is in the hash it is NOT replaced when another record for the same userid is encountered.&amp;nbsp; That is, it keeps the &lt;EM&gt;&lt;STRONG&gt;first instance&lt;/STRONG&gt;&lt;/EM&gt; of each userid.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The &lt;EM&gt;&lt;STRONG&gt;ordered:'A'&lt;/STRONG&gt;&lt;/EM&gt; parameter tells sas to maintain the hash object in ascending order by the key (userid).&amp;nbsp; I.e. your want dataset will be sorted by userid, with one record per userid.&amp;nbsp; This can be a good deal more efficient than sorting the original unreduced dataset file by userid.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Sep 2020 04:35:33 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-09-05T04:35:33Z</dc:date>
    <item>
      <title>Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681777#M79469</link>
      <description>&lt;P&gt;I am trying to get the login data for users displayed per day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I want the first login only for that user and I want it per day (users log in multiple times per day and so I only want their first login for that day), I have been struggling to get it per day, any help would be much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 03:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681777#M79469</guid>
      <dc:creator>RALL</dc:creator>
      <dc:date>2020-09-05T03:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681779#M79470</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266526"&gt;@RALL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to get the login data for users displayed per day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I want the first login only for that user and I want it per day (users log in multiple times per day and so I only want their first login for that day), I have been struggling to get it per day, any help would be much appreciated.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sample data please, in the form of a data step.&amp;nbsp; Followed by the desired result, also in the form of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help us help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note:&amp;nbsp; Let's assume your data are sorted chronologically, so each userid appears scattered throughout the data set.&amp;nbsp; This is a case where the efficiency of hash object shines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if 0 then set have;
  declare hash h (dataset:'have',ordered:'A');
    h.definekey('userid');
    h.definedata(all:'Y');
    h.definedone();
  h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works because:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;By default, the hash object (think lookup table) will keep only one &lt;EM&gt;&lt;STRONG&gt;dataitem&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; (i.e. one record) per key (i.e. per userid).&lt;/LI&gt;
&lt;LI&gt;Also by default, once a given key is in the hash it is NOT replaced when another record for the same userid is encountered.&amp;nbsp; That is, it keeps the &lt;EM&gt;&lt;STRONG&gt;first instance&lt;/STRONG&gt;&lt;/EM&gt; of each userid.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The &lt;EM&gt;&lt;STRONG&gt;ordered:'A'&lt;/STRONG&gt;&lt;/EM&gt; parameter tells sas to maintain the hash object in ascending order by the key (userid).&amp;nbsp; I.e. your want dataset will be sorted by userid, with one record per userid.&amp;nbsp; This can be a good deal more efficient than sorting the original unreduced dataset file by userid.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 04:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681779#M79470</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-05T04:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681783#M79471</link>
      <description>&lt;P&gt;Sort by user, date and time, then run a data step with BY user date, and use a subsetting if first.date.&lt;/P&gt;
&lt;P&gt;For detailed help, supply example data in a data step with datalines, against which we can write the code.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 04:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681783#M79471</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-05T04:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681784#M79472</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Time (UTC)&lt;/TD&gt;&lt;TD&gt;User&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:57.9&lt;/TD&gt;&lt;TD&gt;GG&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:57.4&lt;/TD&gt;&lt;TD&gt;DD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:57.2&lt;/TD&gt;&lt;TD&gt;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TD&gt;&lt;TD&gt;03:55.4&lt;/TD&gt;&lt;TD&gt;CC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:55.1&lt;/TD&gt;&lt;TD&gt;EE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:55.0&lt;/TD&gt;&lt;TD&gt;DD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:54.8&lt;/TD&gt;&lt;TD&gt;CC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:54.8&lt;/TD&gt;&lt;TD&gt;BB&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/05/2020&lt;/TD&gt;&lt;TD&gt;03:54.7&lt;/TD&gt;&lt;TD&gt;AA&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sat, 05 Sep 2020 05:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681784#M79472</guid>
      <dc:creator>RALL</dc:creator>
      <dc:date>2020-09-05T05:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681785#M79473</link>
      <description>&lt;P&gt;please try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by user date time;
run;

data want;
set have;
by user date time;
if first.user;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Sep 2020 05:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681785#M79473</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-09-05T05:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681787#M79474</link>
      <description>&lt;P&gt;Since you did not provide your data in a data step as requested, I have to&amp;nbsp;&lt;EM&gt;assume&lt;/EM&gt;&amp;nbsp;that your date and time column are actually SAS dates and times.&lt;/P&gt;
&lt;P&gt;So my previous suggestion turns into this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by user date time;
run;

data want;
set have;
by user date;
if first.date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Sep 2020 06:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681787#M79474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-05T06:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select first login only per day</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681942#M79488</link>
      <description>&lt;TABLE width="782"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="251.67"&gt;
&lt;P&gt;Date (UTC)&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="287.59"&gt;User&lt;/TD&gt;
&lt;TD width="241.74"&gt;Username&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;TABLE width="175"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="175"&gt;2020-08-31:20:46:49&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;I combined my date and time columns to make the column DATE (UTC) &lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;as above and ran the code as follows&lt;/SPAN&gt; (they where separate date and time columns) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;data ral.Sigins_dups_Removed1;&lt;BR /&gt;set ral.SIGNINS_COMBINED;&lt;BR /&gt;by username 'Date (UTC)'n;&lt;BR /&gt;if first.username;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;It is not giving me the the first sigin by day anymore, any idea what I need to change?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 02:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-first-login-only-per-day/m-p/681942#M79488</guid>
      <dc:creator>RALL</dc:creator>
      <dc:date>2020-09-07T02:24:42Z</dc:date>
    </item>
  </channel>
</rss>

