SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 07:02 AM
    Dear all,

    I have a question, how can I export all variable names with label and column width and measure as variable view showed  to excel or csv file? 

    thanks!

    regards,

    ------------------------------
    xq OW
    ------------------------------

    #SPSSStatistics


  • 2.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 09:16 AM
    Run the DISPLAY DICTIONARY command.  That will produce a table with this information.  You can then export that from the Viewer in whatever format you want.  Alternatively, you can use OMS to export the Variable Information table in Excel or other formats.  The OMS table type is
    'Variable Information'


    --





  • 3.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 09:24 AM
    thank you Jon for the quick reply! 

    regards,


    ------------------------------
    xq OW
    ------------------------------



  • 4.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 09:20 AM
    Here is one way to get a lot of those things into XL:

    
    file handle temp /name="/Users/rick/tmp/example.sav".
    file handle xl   /name="/Users/rick/tmp/example.xlsx".
    
    oms select tables
     /if subtypes='Variable Information' /destination format=sav outfile=temp.
    display variables.
    omsend.
    
    get file temp /drop Command_ Subtype_ Label_.
    
    SAVE TRANSLATE OUTFILE=xl /TYPE=XLS /VERSION=12
      /MAP /FIELDNAMES VALUE=NAMES /CELLS=VALUES /REPLACE
      /DROP=Command_ Subtype_ Label_ Role WriteFormat Position.
    
    erase file temp.
    
    Substitute your path/file names where I have mine in the FILE HANDLE commands.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 5.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 09:25 AM
    thank you Rick for the quick reply!  I will try your suggestions :-)

    regards,

    ------------------------------
    xq OW
    ------------------------------



  • 6.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 09:26 AM
    Sorry, it won't work due to my syntax error. This is what you want for SAVE TRANSLATE:

    SAVE TRANSLATE OUTFILE=xl /TYPE=XLS /VERSION=12
      /MAP /FIELDNAMES VALUE=NAMES /CELLS=VALUES /REPLACE
      /DROP=Role WriteFormat Position.
    ​


    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 7.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 09:42 AM
    Hi Rick

    I tried this, but it doesn't work 

    get file =myfile.
    oms select tables
    /if subtypes='Variable Information' /destination format=sav outfile="C:/Users/xq/temp/out.sav"
    display variables.
    omsend.


    ------------------------------
    xq OW
    ------------------------------



  • 8.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 10:16 AM
    Looks like you may be missing a period at the end of a command. I added it below. Copy this and try it again.

    get file =myfile.
    oms select tables
     /if subtypes='Variable Information' /destination format=sav outfile="C:/Users/xq/temp/out.sav".
    display variables.
    omsend.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 9.  RE: export variable label and column width to excel or csv export

    Posted Wed February 23, 2022 10:26 AM
    ohh yes! it works fine now! many thanks Rick!

    best regards,

    ------------------------------
    xq OW
    ------------------------------