<?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 delete a variable when it has constant values for a certain period? in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416696#M4082</link>
    <description>&lt;P&gt;Use by group processing and the lag functions within a data step to determine firms to delete, then merge:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data del (keep=firm);
set sascomm.aerospacedefense;
by firm;
retain flag;
plag1 = lag(price);
plag2 = lag2(price);
if first.firm then flag = 0;
if lag(firm) = lag2(firm) = firm and plag1 = plag2 = price then flag = 1;
if last.firm and flag then output;
run;

data want;
merge
  sascomm.aerospacedefense
  del (in=d)
;
by firm;
if not d;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Nov 2017 14:15:00 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-11-28T14:15:00Z</dc:date>
    <item>
      <title>How to delete a variable when it has constant values for a certain period?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416682#M4079</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing an event study with trading data using SAS Studio and I need to delete any stocks from my data set which have not been traded, i.e. their closing prices do not change over time. I have a sample of stocks with about 150 trading day records. My (for this task relevant) variables are date, firm and price. So what I want to do is to delete any firms which have not been traded for 3 days in a row or more. I attached one of my data sets. Does anybody know how to do this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 13:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416682#M4079</guid>
      <dc:creator>Annalena</dc:creator>
      <dc:date>2017-11-28T13:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a variable when it has constant values for a certain period?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416687#M4080</link>
      <description>&lt;P&gt;Do you have a target date, eg "has not been traded in the last three days immediately before ...", or does any sequence of three days without a change qualify for deletion?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 14:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416687#M4080</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-28T14:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a variable when it has constant values for a certain period?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416690#M4081</link>
      <description>&lt;P&gt;My estimation window is from April 1 to November 8, so any series of three days or more of no trading before November 8, 2016 qualifies for deletion.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 14:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416690#M4081</guid>
      <dc:creator>Annalena</dc:creator>
      <dc:date>2017-11-28T14:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete a variable when it has constant values for a certain period?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416696#M4082</link>
      <description>&lt;P&gt;Use by group processing and the lag functions within a data step to determine firms to delete, then merge:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data del (keep=firm);
set sascomm.aerospacedefense;
by firm;
retain flag;
plag1 = lag(price);
plag2 = lag2(price);
if first.firm then flag = 0;
if lag(firm) = lag2(firm) = firm and plag1 = plag2 = price then flag = 1;
if last.firm and flag then output;
run;

data want;
merge
  sascomm.aerospacedefense
  del (in=d)
;
by firm;
if not d;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 14:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-delete-a-variable-when-it-has-constant-values-for-a/m-p/416696#M4082</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-28T14:15:00Z</dc:date>
    </item>
  </channel>
</rss>

