SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Variable Names Syntax

    Posted Mon February 15, 2021 01:09 PM

    Morning, I need to pull out specific variable names out of a very large file. They have a pattern, but it's the 'name' within spss not the rows that i need to key off of.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 2.  RE: Variable Names Syntax

    Posted Mon February 15, 2021 02:42 PM

    You can use ADD FILESs to cut your dataset down to a specified list of variables. For example,

    add files /file=* /keep = salary jobcat.

    If you can do the selection by specifying a regular expression, try the SPSSINC SELECT VARIABLES extension command, which you can install from the Extensions > Extension Hub menu. E.g.

    SPSSINC SELECT VARIABLES MACRONAME = !age /PROPERTIES PATTERN= ".*age".

    would create a macro named !age listing all the names containing "age". Then you could used that in add files:

    add files /file=* /keep !age.

    Using this command, you can also base selection on variable type and other metadata.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 3.  RE: Variable Names Syntax

    Posted Wed February 17, 2021 01:43 PM

    Thanks this was very helpful. It doesn't want to call the file when like this:

    SPSSINC SELECT VARIABLES MACRONAME = "!name" /PROPERTIES PATTERN= ".*Percentile".

    GET FILE='E:\Data\2018\File Name.sav' /keep pin !name.


    But seems to do better when run like this for some reason?


    GET FILE='E:\Data\2018\File Name.sav'.

    SPSSINC SELECT VARIABLES MACRONAME = "!name" /PROPERTIES PATTERN= ".*Percentile".

    GET FILE='E:\Data\2018\File Name.sav' /keep pin !name.







    #SPSSStatistics
    #Support
    #SupportMigration


  • 4.  RE: Variable Names Syntax

    Posted Wed February 17, 2021 02:15 PM

    You have to have the file open in order to run SELECT VARIABLES since it uses the dictionary of the active file. However, once the file is open and you have defined the macro, you can just write

    GET FILE=* /keep pin !name.

    You don't need to reopen it.






    #SPSSStatistics
    #Support
    #SupportMigration