<?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: filling missing values in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288975#M899</link>
    <description>&lt;P&gt;Actually, that's a perfect situation.&amp;nbsp; My timestamp requirements could be restated this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever a timestamp is earlier than the previous timestamp, that signals that the day should change.&amp;nbsp; In fact, that's the only reliable signal that the day should change.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2016 17:32:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-08-02T17:32:16Z</dc:date>
    <item>
      <title>filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288631#M889</link>
      <description>&lt;P&gt;I have a dataset sorted by date and time with missing values.I have not&amp;nbsp; been able to fill in those missingvalues&amp;nbsp;by both end successfully, means only previous value has been succeeded.The set is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Price&lt;/U&gt;&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20:12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;1440&lt;/P&gt;&lt;P&gt;20030223&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23:57&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1200&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23:59&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1150&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00:01&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1100&lt;/P&gt;&lt;P&gt;20030224&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02:34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output should be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Price&lt;/U&gt;&lt;/P&gt;&lt;P&gt;20030223&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20:12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1440&lt;/P&gt;&lt;P&gt;20030223&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23:57&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1200&lt;/P&gt;&lt;P&gt;20030223&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23:59&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1150&lt;/P&gt;&lt;P&gt;20030224&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00:01&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1100&lt;/P&gt;&lt;P&gt;20030224&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02:34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 15:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288631#M889</guid>
      <dc:creator>gnrslasher37</dc:creator>
      <dc:date>2016-08-01T15:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288645#M890</link>
      <description>&lt;P&gt;The problem I see it is that you can't say for certain that&amp;nbsp;th missings are any date at all, the first row could be 20:12 on 22feb2016, or 21feb2016 or 24feb2016. &amp;nbsp;There's no logical way of telling from that data what each row's date is, and that can only come really from the system which does know. &amp;nbsp;Now its possible to do, however I don't recommend just guessing like this. &amp;nbsp;Assign a day based on the data order, i.e. retain day starting at 0, then when time &amp;lt; previous time, assume its gone over 24:00, so add one to day. &amp;nbsp;Then get the minimum date, and add day to it for each row. &amp;nbsp;However not really a good logical approach.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 16:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288645#M890</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-01T16:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288659#M892</link>
      <description>&lt;P&gt;Here's an approach ... but it works only under strict conditions.&amp;nbsp; First, for each group of observations there must be exactly one observation with a nonmissing DATE.&amp;nbsp; Second, the TIME values must be legitimate SAS time values, not a character string.&amp;nbsp; Finally, the TIME value for the first observation on a new date must come before the last TIME value from the previous date.&amp;nbsp; (For example using your sample data, 00:01 must be earlier than 23:59.)&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;timedif = dif(time);&lt;/P&gt;
&lt;P&gt;if timedif &amp;lt; 0 then set have (keep=date where=(date &amp;gt; .) rename=(date=replacement_date));&lt;/P&gt;
&lt;P&gt;date = replacement_date;&lt;/P&gt;
&lt;P&gt;drop timedif;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 17:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288659#M892</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-01T17:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288666#M893</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;, I think you might have overlooked one tiny detail, that is for a dataset option, 'where' happens after 'rename', so it should be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if timedif &amp;lt; 0 then set have (keep=date where=(replacement_date &amp;gt; .) rename=(date=replacement_date));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80400"&gt;@gnrslasher37﻿&lt;/a&gt;, &amp;nbsp;the following approach requires almost the same condition as the one provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;, except you can have multiple populated 'date' value within the same day, and the only thing to determine if a new date starts is the current 'time' less than or equal to the last 'time'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Date                Time :time5.           Price;
	format time time5.;
	cards;
.                      20:12          1440
20030223       23:57          1200
.                      23:59          1150
.                      00:01          1100
20030224       02:34          1400
;

data want;
	do _n_=1 by 1 until (time &amp;gt;= _t);
		set have;
		set have(firstobs=2 rename=(time=_t)) have(obs=1 drop=_all_);

		if not missing(date) then
			_d=date;
	end;

	do _n=1 to _n_;
		set have;
		date=_d;
		output;
	end;

	drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 17:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288666#M893</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-01T17:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288669#M894</link>
      <description>&lt;P&gt;That's absolutely right, my SET statement should read:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if timedif &amp;lt; 0 then set have (keep=date where=(&lt;FONT color="#FF0000"&gt;replacement_&lt;/FONT&gt;date &amp;gt; .) rename=(date=replacement_date));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good catch.&amp;nbsp; Note to self:&amp;nbsp; check your code!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 18:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288669#M894</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-01T18:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288813#M895</link>
      <description>&lt;PRE&gt;
What if there are some missing DATE at the end of table , what you gonna do ?

data have;
	input Date                Time :time5.           Price;
	format time time5.;
	cards;
.                      20:12          1440
20030223       23:57          1200
.                      23:59          1150
.                      00:01          1100
20030224       02:34          1400
.       02:34          1400
.       02:34          1400
;
run;

data want;
retain temp1 temp2;
 do until(not missing(date) or last1);
  set have end=last1;
 end;
 if not missing(date) then temp1=date;

n+1;

 do until(not missing(date) or last2);
  set have end=last2;
  if n=1 then new_date=ifn(missing(date),temp1,date);
   else new_date=ifn(missing(date),temp2,date);
  output;
 end;
 if not missing(date) then temp2=date;

drop temp1 temp2 n; 
run;

&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Aug 2016 04:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288813#M895</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-02T04:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288832#M896</link>
      <description>&lt;P&gt;The dataset has multiple timestamp data within a 24 hour circle of the day, thus the time interval will be looping in same way for each different day. So the time constraints you have mentioned cannot be hold up.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 06:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288832#M896</guid>
      <dc:creator>gnrslasher37</dc:creator>
      <dc:date>2016-08-02T06:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: filling missing values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288975#M899</link>
      <description>&lt;P&gt;Actually, that's a perfect situation.&amp;nbsp; My timestamp requirements could be restated this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever a timestamp is earlier than the previous timestamp, that signals that the day should change.&amp;nbsp; In fact, that's the only reliable signal that the day should change.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 17:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/filling-missing-values/m-p/288975#M899</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-02T17:32:16Z</dc:date>
    </item>
  </channel>
</rss>

