<?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: Determine standing from two columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466598#M119063</link>
    <description>&lt;P&gt;Assuming i understood correctly:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id	status	 $ date :mmddyy10.;
format date mmddyy10.;
cards;
1	In	5/14/2015
1	out	6/15/2016
2	in	3/3/2013
2	out	5/22/2014
2	in	1/3/2015
2	out	3/3/2015
3	in	1/8/2016
4	in	6/6/2016
4	out	5/31/2017
;
/*51017*/

data want;
set have;
by id;
if last.id;
length InAsof51017 $8;
InAsof51017='YES';
if upcase(status)="OUT" and date&amp;lt;='10may2017'd then InAsof51017='NO';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 31 May 2018 19:13:46 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-31T19:13:46Z</dc:date>
    <item>
      <title>Determine standing from two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466596#M119061</link>
      <description>&lt;P&gt;I’m trying to determine cases who were in as of 5-10-2017.&lt;/P&gt;&lt;P&gt;Here is the data that I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;status&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;In&lt;/TD&gt;&lt;TD&gt;5/14/2015&lt;/TD&gt;&lt;/T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lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions as to how to get this?&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 18:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466596#M119061</guid>
      <dc:creator>hwangnyc1</dc:creator>
      <dc:date>2018-05-31T18:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Determine standing from two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466597#M119062</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select i.id,i.date as in_date,o.date as out_date,
        case when '10MAY2017'd &amp;gt;= i.date and '10MAY2017'd &amp;lt;= o.date then 'yes'
        else 'no' end as in_or_out
    from have(where=(status='In')) as i left join have(where=(status='out')) as o
    on i.id=o.id order by i.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 19:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466597#M119062</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-31T19:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Determine standing from two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466598#M119063</link>
      <description>&lt;P&gt;Assuming i understood correctly:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id	status	 $ date :mmddyy10.;
format date mmddyy10.;
cards;
1	In	5/14/2015
1	out	6/15/2016
2	in	3/3/2013
2	out	5/22/2014
2	in	1/3/2015
2	out	3/3/2015
3	in	1/8/2016
4	in	6/6/2016
4	out	5/31/2017
;
/*51017*/

data want;
set have;
by id;
if last.id;
length InAsof51017 $8;
InAsof51017='YES';
if upcase(status)="OUT" and date&amp;lt;='10may2017'd then InAsof51017='NO';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 19:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466598#M119063</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-31T19:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Determine standing from two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466607#M119066</link>
      <description>&lt;P&gt;I would try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if first.id then InAsof51017 = 'yes';&lt;/P&gt;
&lt;P&gt;retain InAsof51017;&lt;/P&gt;
&lt;P&gt;status = upcase(status);&lt;/P&gt;
&lt;P&gt;if status = 'IN' and date &amp;gt; '05May2017'd then InAsof51017 = 'no';&lt;/P&gt;
&lt;P&gt;else if status = 'OUT' and date &amp;lt;= '05May2017'd then InAsof51017 = 'no';&lt;/P&gt;
&lt;P&gt;if last.id;&lt;/P&gt;
&lt;P&gt;keep id InAsof51017;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 19:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466607#M119066</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-31T19:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Determine standing from two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466612#M119068</link>
      <description>&lt;P&gt;A datastep solution:&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 id date; run;

data want;
length inAsOf $3;
do until(last.id);
    set have; by id;
    if status = "in" then inDate = date;
    if status = "out" then do;
        if missing(inAsOf) and inDate &amp;lt;= '10MAY2017'd &amp;lt; date then inAsOf = "Yes";
        call missing(inDate);
        end;
    end;
if missing(inAsOf) then do;
    if missing(inDate) then inAsOf = "No";
    else if inDate &amp;gt; '10MAY2017'd then inAsOf = "No";
    else inAsOf = "Yes";
    end;
drop inDate status date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 19:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-standing-from-two-columns/m-p/466612#M119068</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-31T19:46:39Z</dc:date>
    </item>
  </channel>
</rss>

