Command Reference : Command Reference
  
 
copy
Copy an object, or a set of objects matching a name pattern, within and between workfiles, workfile pages, and databases. Data in series objects may be frequency converted or match merged.
Syntax
copy(options) src_spec dest_spec [src_id dest_id]
copy(options) src_spec dest_spec [@src src_ids @dest dest_id]
where src_spec and dest_spec are of the form:
[ctype][container::][page\]object_name
There are three parts to the copy command: (1) a specification of the location and names of the source objects; (2) a specification of the location and names of the destination objects; (3) optional source and destination IDs if the copy operation involves match merging.
The source and destination objects are specified in multiple (optional) parts: (1) the container specification is the name of a workfile or database; (2) the page specification is the name of a page within a workfile or a subdirectory within a database; and (3) the object_name specification is the name of an object or a wildcard pattern corresponding to multiple objects.
The ctype specification is rarely required, but permits you to specify precisely your source or destination in cases where a database and workfile share the same name. In this case, ctype may be used to indicate the container to which you are referring by prefixing the container name with “:” to indicate the workfile, or “::” to indicate the database with the common name.
When parts of the source or destination specification are not provided, EViews will fill in default values where possible. The default container is the active workfile, unless the “::” prefix is used in which case the default container is the default database. The default page within a workfile is always the active page. The default name for the destination object is the name of the object within the source container.
If ID series are not provided in the command, then EViews will perform frequency conversion when copying data whenever the source and destination containers have different frequencies. If ID series are provided, then EViews will perform a general match merge between the source and destination using the specified ID series. In the case where you wish to copy your data using match merging with special treatment for date matching, you must use the special keyword “@DATE” as an ID series for the source or destination. If “@DATE” is not specified as an identifier in either the source or destination IDs, EViews will perform an exact match merge using the given identifiers.
If ID series are not specified, but a conversion option requiring a general match merge is used (e.g., “c=med”), “@DATE @DATE” will be appended to the list of IDs and a general date match merge will be employed.
See Link::linkto for additional discussion of the differences embodied in these choices.
The general syntax described above covers all possible uses of the copy command. The following paragraphs provide examples of the specific syntax used for some common cases of the command.
Copying Within a Workfile
Copy an object within the default workfile page as a new object with a different name:
copy(options) src_name dest_name
Copy an object from the src_page page into the default workfile page using the specified name:
copy(options) src_page\src_name dest_name
Copy an object from the src_page page into the dest_page page, keeping the same name:
copy(options) src_page\src_names dest_page\
Copy an object from the src_page page to the default workfile page, match merging any series data using a single src_id and a single dest_id identifier series:
copy(options) src_page\src_name dest_name src_id dest_id
Copy an object from the src_page page to the dest_page match merging any series data using multiple source and destination identifier series:
copy(options) src_page\src_name dest_page\dest_name @src src_id1 src_id2 ... src_id_n @dest dest_id1 dest_id2 ... dest_id_n
Copying Between Containers (Workfiles and Databases)
Copy one or more objects from the src_page of the workfile src_workfile to the dest_page of the workfile dest_workfile, using the name or name pattern given in src_names:
copy(options) src_workfile::src_page\src_names dest_workfile::dest_page\
Copy an object from database src_database to the default page in the container dest_container:
copy(options) src_database::src_name dest_container::dest_name
Note that if both a workfile and database exist matching the name provided in dest_container, EViews will favor the workfile unless the “::” prefix is used to specify explicitly that the database should be used.
Options
Basic Options
 
overwrite / o
Overwrite any existing object with the destination name in the destination container. Error only if a non-editable series is encountered in the destination location.
merge / m
If the source object is a series, merge the data from the source series into any existing destination series, preserving any values in the destination series that are not present in the source. For all other object types, overwrite any existing object with the source object. Error if a non-editable series is encountered in the destination location.
protect / p
Protect objects in the destination location from overwriting or merging. If there is an existing object in the destination container, cancel the copy operation for that object, but do not generate an error.
noerr
Suppress errors that are generated during the copy. For example, if the overwrite option is used, suppress any error caused by attempting to overwrite a non-editable series such as an index series used in the workfile structure.
link
Link the object to the source data so that the values can be refreshed at a later time.
Group Copy Options
When copying a group object from workfile to database:
 
g=arg
Method for copying group objects from a workfile to database: “s” (copy group definition and series as separate objects), “t” (copy group definition and series as one object), “d” (copy series only as separate objects), “l” (copy group definition only).
When copying a group object from a database to a workfile:
 
g=arg
Method for copying group objects from a database or workfile to a workfile: “b” (copy both group definition and series), “d” (copy only the series), “l” (copy only the group definition).
Note that copying a group object containing expressions or auto-updating series between workfiles only copies the expressions, and not the underlying series.
Frequency Conversion Options
If the copy command does not specify identifier series, EViews will perform frequency conversion of the data contained in series objects whenever the source and destination containers are dated, but do not have the same frequency.
If either of the pages are undated, EViews will, unless match merge options are provided (as described below), perform a raw copy, in which the first observation in the source workfile page is copied into the first observation in the destination page, the second observation in the source into the second observation in the destination, and so forth.
The following options control the frequency conversion method when copying series and group objects into a workfile page and converting from low to high frequency:
 
c=arg
Low to high conversion methods: “r” or “repeata” (constant match average), “d” or “repeats” (constant match sum), “q” or “quada” (quadratic match average), “t” or “quads” (quadratic match sum), “linearf” (linear match first), “i” or “linearl” (linear match last), “cubicf” (cubic match first), “c” or “cubicl” (cubic match last), “pointf” (point first), “pointl” (point last), “dentonf” (Denton first), “dentonl” (Denton last), “dentona” (Denton average), “dentons” (Denton sum), “chowlinf” (Chow-Lin first), “chowlinl” (Chow-Lin last), “chowlina” (Chow-Lin average),“chowlins” (Chow-Lin sum), “litmanf” (Litterman first), “litmanl” (Litterman last), “litmana” (Litterman average), “litmans” (Litterman sum).
rho=arg
Autocorrelation coefficient (for Chow-Lin and Litterman conversions). Must be between 0 and 1, inclusive.
In addition, for Denton, Chow-Lin, and Litterman conversions, you must specify the indicator series by appending the keyword “@indicator” followed by the series name at the end of the copy command.
The following options control the frequency conversion method when copying series and group objects into a workfile page and converting from high to low frequency:
 
c=arg
High to low conversion methods removing NAs: “a” (average of the nonmissing observations), “s” (sum of the nonmissing observations), “f” (first nonmissing observation), “l” (last nonmissing observation), “x” (maximum nonmissing observation), “m” (minimum nonmissing observation).
High to low conversion methods propagating NAs: “an” or “na” (average, propagating missings), “sn” or “ns” (sum, propagating missings), “fn” or “nf” (first, propagating missings), “ln” or “nl” (last, propagating missings), “xn” or “nx” (maximum, propagating missings), “mn” or “nm” (minimum, propagating missings).
Note that if no conversion method is given in the command, the conversion method specified within the series object will be used as the default. If the series does not contain an explicit conversion method, the global option settings will used to determine the method.
Frequency conversion involving panel structured pages involves special handling:
If both pages are dated panel pages that are structured with a single identifier, EViews will perform frequency conversion cross-section by cross-section.
Conversion from a dated panel page to a dated, non-panel page will first perform a mean contraction across cross-sections to obtain a single time series (by computing the means for each period), and then a frequency conversion of the resulting time series to the new frequency.
Conversion from a dated, non-panel page to a dated panel page will first involve a frequency conversion of the single time series to the new frequency. The converted time series will be used for each cross-section in the panel page.
In all three of these cases, all of the high-to-low conversion methods are supported, but low-to-high frequency conversion only offers Constant-match average (repeating of the low frequency observations).
Lastly, conversion involving a panel page with more than one dimension or an undated page will default to raw data copy unless general match merge options are provided.
Match Merge Options
These options are available when ID series are specified in the copy commmand.
 
smpl= smpl_spec
Sample to be used when computing contractions during copying using match merge. Either provide the sample range in double quotes or specify a named sample object. By default, EViews will use the entire workfile sample “@ALL”.
c=arg
Set the match merge contraction method.
If you are copying a numeric source series by general match merge, the argument can be one of: “mean”, “med” (median), “max”, “min”, “sum”, “sumsq” (sum-of-squares), “var” (variance), “sd” (standard deviation), “skew” (skewness), “kurt” (kurtosis), “quant” (quantile, used with “quant=” option), “obs” (number of observations), “nas” (number of NA values), “first” (first observation in group), “last” (last observation in group), “unique” (single unique group value, if present), “none” (disallow contractions).
If copying an alpha series, only the non-summary methods “max”, “min”, “obs”, “nas”, first”, “last”, “unique” and “none” are supported.
For copying of numeric series, the default contraction method is “c=mean”; for copying of alpha series, the default is “c=unique”.
quant=number
Quantile value to be used when contracting using the “c=quant” option (e.g, “quant=.3”).
nacat
Treat “NA” values as a category when copying using general match merge operations.
Most of the conversion options should be self-explanatory. As for the others: “first” and “last” give the first and last non-missing observed for a given group ID; “obs” provides the number of non-missing values for a given group; “nas” reports the number of NAs in the group; “unique” will provide the value in the source series if it is the identical for all observations in the group, and will return NA otherwise; “none” will cause the copy to fail if there are multiple observations in any group—this setting may be used if you wish to prohibit all contractions.
On a match merge expansion, copying with match merging will repeat the value of the source for every observation with matching identifier values in the destination. If both the source and destination have multiple values for a given ID, EViews will first perform a contraction across IDs in the source (if not ruled out by “c=none”), and then perform the expansion by replicating the contracted value in the destination. For example, converting from a quarterly panel to an annual panel using match merge, EViews will first contract the data across IDs down to a single quarterly time series, will convert the series to an annual frequency, then will assign the annual data to each of the cross-sections in the destination page.
Examples
copy good_equation best_equation
makes an exact copy of GOOD_EQUATION and names it BEST_EQUATION.
copy graph_1 wf2::wkly\graph1
copies GRAPH_1 from the default page of the current workfile to GRAPH1 in the page WKLY of the workfile WF2.
copy gdp usdat::
copies GDP from the current workfile to GDP in the USDAT database or workfile.
copy ::gdp macro1::gdp_us
copies GDP from the default database to either the open workfile MACRO1, or the database named MACRO1 if there is no open workfile with that name. If there is an open workfile MACRO1 you may use
copy ::gdp ::macro1::gdp_us
to specify explicitly that you wish to write to the MACRO1 database.
copy(smpl="1990 2000") page1\pop page2\ @src county @date @dest county @date
copies POP data for 1990 through 2005 from PAGE1 to PAGE2, match merge using the ids COUNTY and the date structure of the two pages.
copy(smpl="1990 2000", c=mean) panelpage\inc countypage\ county county
copies the INC data from the PANELPAGE to the COUNTYPAGE, match merging using the values of the COUNTY series, and contracting the panel data by computing means for each county using the specified sample.
copy countypage\pop panelpage\ county county
match merges the POP data from the COUNTYPAGE to the PANELPAGE using the values of the COUNTY series.
copy(c=x, merge) quarterly::page1\ser* annual::page6\*
copies all objects with names beginning with “SER” on page PAGE1 of workfile QUARTERLY into page PAGE6 of workfile ANNUAL using the existing names. Series objects with data that can be (high-to-low) frequency converted will take the maximum value within a low-frequency period as the conversion method. If destination series already exist with the same name as the source series, the data will be merged. If destination objects (non-series) exist with the same name as source series, they will be overwritten.
Note that since databases are read from disk, you may provide a path for the database in the container specification, as in:
copy "c:\my data\dba.edb::ser01" ser02
which copies the object SER01 from the database DBA.EDB located in the path “C:\MY DATA\” to SER02 in the default workfile page.
copy gd* "c:\my data\findat::"
makes a duplicate of all objects in the default page of the current workfile with names starting with “GD” to the database FINDAT in the root of “C:\MY DATA\”.
Cross-references
See “Copying Objects” for a discussion of copying and moving objects.
See also fetch, store, and Link::linkto.