Copy dictionary information (attributes) from another dataset.

Frequently variable attributes (e.g. variable and value labels) in different datasets are the same or similar. This commands allows to copy all or selected attributes from a dataset to the current.

Menu

APPLY DICTIONARY

APPLY DICTIONARY FROM "file1.sav"/NEWVARS.
Creates a new empty dataset with all attributes of all variables from file1.sav.

APPLY DICTIONARY from * 
   /SOURCE variablesl =V1 /TARGET variables= v2 v3 v4 v6/VARINFO MISSING VALLABELS.
   
   APPLY DICTIONARY from * 
   /SOURCE variablesl =V1 /TARGET variables= v2 v3 v4 v6/VARINFO MISSING VALLABELS = MERGE.

APPLY DICTIONARY from *
  /SOURCE VARIABLES = var1
  /TARGET VARIABLES = var2 var3 var4
  /NEWVARS.
• Variable definition attributes for var1 in the active dataset are copied to var2, var3, and var4 in the same dataset 
if they have a matching type.

• Any variables specified in the TARGET subcommand that do not already exist are created, 
using the variable definition attributes of the variable specified in the SOURCE subcommand.


  Variable mapping for SOURCE and TARGET subcommands
SOURCE subcommand TARGET subcommand Variable mapping 
none
 none
 Variable definition attributes from the source dataset are applied to matching variables in the active (target) dataset. New variables may be created if the NEWVARS subcommand is specified.
 
many
 none
 Variable definition attributes for the specified variables are copied from the source dataset to the matching variables in the active (target) dataset. All specified variables must exist in the source dataset. New variables may be created if the NEWVARS subcommand is specified.
 
none
 many
 Variable definition attributes for the specified variables are copied from the source dataset to the matching variables in the active (target) dataset. All specified variables must exist in the source dataset. New variables may be created if the NEWVARS subcommand is specified.
 
one
 many
 Variable definition attributes for the specified variable in the source dataset are applied to all specified variables in the active (target) dataset that have a matching type. New variables may be created if the NEWVARS subcommand is specified.
 
many
 many
 Invalid. Command not executed.
 


Example
APPLY DICTIONARY from “lastmonth.sav”
  /SOURCE VARIABLES = var1, var2, var3.
• Variable definition attributes from the specified variables in the source dataset are applied to the matching variables in the active dataset.

• For variables with matching names but different types, only variable labels from the source variable are copied to the target variable.

• In the absence of a NEWVARS subcommand, no new variables will be created.


  ALIGNMENT Applies variable alignment for Data Editor display. This setting affects alignment (left, right, center) only in the Data View display of the Data Editor.  
ATTRIBUTES Applies file attributes defined by the VARIABLE ATTRIBUTE command. You can REPLACE or MERGE variable attributes.  
FORMATS Applies variable print and write formats. This is the same variable definition attribute that can be defined with the FORMATS command. This setting is primarily applicable only to numeric variables. For string variables, this affects only the formats if the source or target variable is AHEX format and the other is A format.  
LEVEL Applies variable measurement level (nominal, ordinal, scale). This is the same variable definition attribute that can be defined with the VARIABLE LEVEL command. 
MISSING Applies variable missing value definitions. Any existing defined missing values in the matching variables in the active dataset are deleted. This is the same variable definition attribute that can be defined with the MISSING VALUES command. Missing values definitions are not applied to string variables if the source variable contains missing values of a longer width than the defined width of the target variable. 
VALLABELS Applies value label definitions. Value labels are not applied to string variables if the source variable contains defined value labels for values longer than the defined width of the target variable. You can REPLACE or MERGE value labels. 
  VALLABELS = REPLACE replaces any defined value labels from variable in the active dataset with the value labels from the matching variable in the source dataset. 
  VALLABELS = MERGE merges defined value labels for matching variables. If the same value has a defined value label in both the source and active datasets, the value label in the active dataset is unchanged. 
WIDTH Display column width in the Data Editor. This affects only column width in Data View in the Data Editor. It has no affect on the defined width of the variable. 

Example
APPLY DICTIONARY from “lastmonth.sav”
  /VARINFO LEVEL MISSING VALLABELS = MERGE.
---

/VARINFO
[/VARINFO [ALIGNMENT**]  ]


           [ATTRIBUTES = [{REPLACE}]]
                          {MERGE  } 
           [FORMATS**] 

           [LEVEL**] 

           [MISSING**]

           [VALLABELS = [{REPLACE**}]] 
                         {MERGE   }

           [VARLABEL**] 

           [WIDTH**] 

           [ALL]
  
  Thanks Jon.  Here is an example from the Help file:

APPLY DICTIONARY from *
  /SOURCE VARIABLES = var1
  /TARGET VARIABLES = var2 var3 var4
  /NEWVARS.

• Variable definition attributes for var1 in the active dataset are
copied to var2, var3, and var4 in the same dataset if they have a
matching type.

• Any variables specified in the TARGET subcommand that do not already
exist are created, using the variable definition attributes of the
variable specified in the SOURCE subcommand.

Am I correct in thinking that APPLY DICTIONARY did not always have
this capability?  Presumably, Raynald would not have written his macro
if he could have done this.

-- 
Bruce Weaver
bwea...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

    Forward  
		
		
		

> > You can do this with APPLY DICTIONARY (aka Data>Copy Data Properties)

> > Regards,
> > Jon Peck

> Thanks Jon.  Here is an example from the Help file:

> APPLY DICTIONARY from *
>   /SOURCE VARIABLES = var1
>   /TARGET VARIABLES = var2 var3 var4
>   /NEWVARS.

> • Variable definition attributes for var1 in the active dataset are
> copied to var2, var3, and var4 in the same dataset if they have a
> matching type.

> • Any variables specified in the TARGET subcommand that do not already
> exist are created, using the variable definition attributes of the
> variable specified in the SOURCE subcommand.

> Am I correct in thinking that APPLY DICTIONARY did not always have
> this capability?  Presumably, Raynald would not have written his macro
> if he could have done this.

> --

The original APPLY DICTIONARY command was much more rigid, but it was
reworked sometime around version 14.
Note that the command allows you to just copy value labels by
specifying /VARINFO VALLABELS=MERGE or REPLACE.