Groups | Search | Server Info | Login | Register


Groups > comp.soft-sys.sas > #964

interpolating missing values

From wyldsoul <wyldsoul@gmail.com>
Newsgroups comp.soft-sys.sas
Subject interpolating missing values
Date 2011-06-20 13:25 -0700
Organization http://groups.google.com
Message-ID <4be0f2da-c05f-40ba-95a7-cda03c9e3854@s16g2000prf.googlegroups.com> (permalink)

Show all headers | View raw


Hi all,
 I want to interpolate missing values from gage data.  This is easy to
do manually in excel, however, I have over 60 years of water level
data from dozens of stage gages, and would like to find a way to batch
interpolate in SAS.   In order to interpolate, for each set of missing
values I need to  calculate the difference between the last
observation before the first blank value and the first observation
after the last blank value.  Then divide the result of this by the
total number of missing values+1.  Simply put:
(first obs± last obs)/(# missing obs+1)
or using the sample data from below: (6.05-6.01)/4=0.01

Then I need to populate each missing observation by cumulatively
adding or subtracting the result of the previous calculation to each
successive blank until you reach the next non-blank observation.
The sample dataset is below.  Stage is the original value, int_factor
is the result of the first calculation, and interp_stage is the
interpolated stage based on cumulatively adding the int_factor to each
observation .


Station	date	stage	int_factor	interp_stage
NP-P33	1-Jan-53	6.04		6.04
NP-P33	2-Jan-53	6.03		6.03
NP-P33	3-Jan-53	6.02		6.02
NP-P33	4-Jan-53	6.01		6.01
NP-P33	5-Jan-53		0.0100	6.02
NP-P33	6-Jan-53			6.03
NP-P33	7-Jan-53			6.04
NP-P33	8-Jan-53	6.05		6.05
NP-P33	9-Jan-53	6.15		6.15
NP-P33	10-Jan-53	6.20		6.2
NP-P33	11-Jan-53	6.20		6.2
NP-P33	12-Jan-53	6.19		6.19
NP-P33	13-Jan-53	6.18		6.18
NP-P33	14-Jan-53	6.17		6.17
NP-P33	15-Jan-53	6.16		6.16
NP-P33	16-Jan-53	6.15		6.15
NP-P33	17-Jan-53	6.14		6.14
NP-P33	18-Jan-53	6.13		6.13
NP-P33	19-Jan-53	6.12		6.12
NP-P33	20-Jan-53		0.0091	6.11
NP-P33	21-Jan-53			6.10
NP-P33	22-Jan-53			6.09
NP-P33	23-Jan-53			6.08
NP-P33	24-Jan-53			6.07
NP-P33	25-Jan-53			6.07
NP-P33	26-Jan-53			6.06
NP-P33	27-Jan-53			6.05
NP-P33	28-Jan-53			6.04
NP-P33	29-Jan-53			6.03
NP-P33	30-Jan-53	6.02		6.02
NP-P33	31-Jan-53	6.02		6.02

Back to comp.soft-sys.sas | Previous | NextNext in thread | Find similar


Thread

interpolating missing values wyldsoul <wyldsoul@gmail.com> - 2011-06-20 13:25 -0700
  Re: interpolating missing values "Kenneth M. Lin" <kenneth_m_lin@sbcglobal.net> - 2011-06-20 15:22 -0700
    Re: interpolating missing values wyldsoul <wyldsoul@gmail.com> - 2011-06-21 07:03 -0700

csiph-web