How do I merge values from a file into a series in memory?
Posted: Mon Sep 14, 2015 4:14 pm
I have a series in memory, and I have a file that contains the same series with a subsample of dates. I'm trying to merge the series in the file with the series already in memory, overwriting values in the original series that occur in the file, while leaving the rest of the series intact. Here's a simple example:
This produces the output
whereas I'm trying to get the gdp series to look like this:
The dates and values in new_values.csv are completely arbitrary and aren't known ahead of time (except that they'll be in the same frequency as the series currently in memory). Is this possible?
Code: Select all
calendar(q) 1940:1
* load original data
open data nipa.csv
data(format = cdf, org = columns, dateform = "m/d/y") / gdp
close data
print 2013:1 2015:4 gdp
* merge new values
open data new_values.csv
data(format = cdf, org = columns) / gdp
close data
print 2013:1 2015:4 gdp
Code: Select all
* <snipped>
ENTRY GDP
2013:01 15457.2
2013:02 15500.2
2013:03 15614.4
2013:04 15761.5
2014:01 15724.9
2014:02 15901.5
2014:03 16068.8
2014:04 16151.4
2015:01 16177.3
2015:02 16270.4
2015:03 NA
2015:04 NA
* merge new value
open data new_values.csv
data(format = cdf, org = columns) / gdp
close data
print 2013:1 2015:4 gdp
ENTRY GDP
2013:01 NA
2013:02 NA
2013:03 NA
2013:04 NA
2014:01 -1
2014:02 NA
2014:03 NA
2014:04 NA
2015:01 NA
2015:02 -2
2015:03 -3
2015:04 NA
Code: Select all
ENTRY GDP
2013:01 15457.2
2013:02 15500.2
2013:03 15614.4
2013:04 15761.5
2014:01 -1
2014:02 15901.5
2014:03 16068.8
2014:04 16151.4
2015:01 16177.3
2015:02 -2
2015:03 -3
2015:04 -4