SPSS Statistics

 View Only
  • 1.  SPSSINC MODIFY OUTPUT Issues

    Posted 6 days ago

    I am using the SPSSINC MODIFY OUTPUT command to output TABLES to specific cell locations in Excel using /CUSTOM FUNCTION="customoutputfunctions.excelexport...", with very inconsistent results.  I got my first round of tables to get placed where they need to be, with some tweaking, but I am unable to get additional tables to consistently go or even appear where they need to be.  Sometimes they show up in the excelexport file, and sometimes they do not. I have several repeating charts that require the use of PROCESS=PRECEDING immediately after the function syntax is executed (EXAMINE VARIABLES, FREQUENCIES VARIABLES, etc), instead of using PROCESS=ALL.  I have the guidance previously sent for this Python custom function, but the parameters (file, sheet, action, location, starting cell, etc) do not consistently work, and I've spent several hours testing different combinations.  I am looking for some kind of tutorial or better explanation for how these work and behave.  So far, I am finding their behavior inconsistent for producing the necessary data at the necessary locations needed for further use.

    Any more detailed guidance would be greatly appreciated! Thx!



    ------------------------------
    Mark Sloan
    ------------------------------


  • 2.  RE: SPSSINC MODIFY OUTPUT Issues

    IBM Champion
    Posted 6 days ago
    MODIFY TABLES is doing all the exporting with the OUTPUT EXPORT command equivalent, so the results would usually be the same.  However, sometimes the Viewer gets behind in rendering the items the backend has sent to it, and as a result, commands such as MODIFY OUTPUT that are looking at the latest output don't see it, because the Viewer hasn't finished rendering them and adding them to the output.

    I have pushed for this to be fixed for years, but the Viewer is doing many things simultaneously on different threads, and the problem can still occur.

    The way to get around this is to add a small delay in the syntax stream just before MODIFY OUTPUT and similar commands are executed.  This small block of code will just wait for two seconds, which is usually enough time for the Viewer to catch up.  You can tinker with the amount of delay.

    begin program python3.
    import time
    time.sleep(2)
    end program.



    --





  • 3.  RE: SPSSINC MODIFY OUTPUT Issues

    Posted 6 days ago

    Thank you for the explanation.  This makes sense.  I have put the MODIFY OUTPUT code immediately following a function with PROCESS=PRECEDING because I have several tables with the same OMS Subtype name, and I don't know of any way to adequately track them or transfer specific ones to Excel otherwise.  I will tinker with the delay, but I do need SPSS to function at its fastest speed as much as possible due to the volume of models I need to run.   I assume that changing time.sleep(1) would change this to 1 second (to test for speed)?

    Thank you so much for your quick response!



    ------------------------------
    Mark Sloan
    ------------------------------



  • 4.  RE: SPSSINC MODIFY OUTPUT Issues

    IBM Champion
    Posted 6 days ago
    Yes, one would mean one second.  You want it to be big enough to overcome the delay, however, so some experimentation may be required.

    --





  • 5.  RE: SPSSINC MODIFY OUTPUT Issues

    Posted 5 days ago
      |   view attached

    It works!  I tested a range of 0.1 to 2 seconds and all values worked.  I plan to use 0.1 seconds moving forward.  Tables are now loading consistently and in the right places.  One small minor issue that is not a big deal for my functionality is table formatting.  It seems that each table appears in Excel formatted differently.  Some have cells filled in with gray or black, and text ranges from light gray to black, rendering the tables unreadable to humans, but not unreadable to Excel (my target audience).  Is there a command/subcommand that could be added at the end that would remove all fills and make all text black, without manual intervention? I've uploaded an image that shows the disparate fills and text colors.

    Thank you for all your help!

      



    ------------------------------
    Mark Sloan
    ------------------------------



  • 6.  RE: SPSSINC MODIFY OUTPUT Issues

    IBM Champion
    Posted 5 days ago
    Great!  I would give time delay just a little more time as the necessary delay might vary slightly.

    The formatting in Excel should approximately match the formatting in SPSS.  There is no control of it.  The Excel color code definitions don't always match the SPSS system, so if you have a table look with colors set, you might switch it or turn it off.
    --





  • 7.  RE: SPSSINC MODIFY OUTPUT Issues

    Posted 4 days ago

    Thanks!  I am now testing using SPSSINC MODIFY OUTPUT on graphs and charts other than tables, but have not cracked the code yet.

    After running a pplot command (which successfully goes to the output window every time), here is an example of syntax I am using, but it is not exporting to Excel:

    begin program python3.
    import time
    time.sleep(2)
    end program.
     
    SPSSINC MODIFY OUTPUT CHARTS
    /IF COMMAND= "'pplot'" PROCESS=PRECEDING
    /CUSTOM FUNCTION="customoutputfunctions.excelexport (file='d:/spss/output1.xls', sheet='InitL1Graphs', action= 'ModifyWorksheet', startingCell='G3', image='jpg')".
    I notice that Q-Q plots (from pplot) and other charts such as histograms, do not have an OMS Subtype.  They only have an OMS command identifier, hence the use of /IF COMMAND="pplot".  Could this be the cause of no success in exporting charts to Excel? Am I missing something in the syntax?
    Thanks!



    ------------------------------
    Mark Sloan
    ------------------------------



  • 8.  RE: SPSSINC MODIFY OUTPUT Issues

    IBM Champion
    Posted 4 days ago
    From the customoutputfunctions doc...

    # This function differs from the OUTPUT EXPORT command in being able to select items
    # via the criteria of the command and in how the output files are structured.  Also, it cannot
    # put graphical items into the target spreadsheet.  They are written to separate files

        # Write graphics objects to separate files named by file and sheet name
        # since ExportToDocument api can't do images
        if obj.GetType() in [SpssClient.OutputItemType.CHART, SpssClient.OutputItemType.TREEMODEL, SpssClient.OutputItemType.MODEL]:
            name = os.path.splitext(filename)[0] + "_" + sheetname
            obj.ExportToImage(name, custom["image"])

    --





  • 9.  RE: SPSSINC MODIFY OUTPUT Issues

    Posted 4 days ago

    Thanks for the clarification.  This looks really complicated. Where could I access the documentation?



    ------------------------------
    Mark Sloan
    ------------------------------



  • 10.  RE: SPSSINC MODIFY OUTPUT Issues

    IBM Champion
    Posted 4 days ago
    The only doc other than what is in the file is what you see in Output Export or File > Export or OMS.  Charts do not have OMS  types, but you can select in customstylefunctions by the COMMAND name along with PRECEDING or ALL.

    --





  • 11.  RE: SPSSINC MODIFY OUTPUT Issues

    Posted 2 days ago

    I forward sample .spv and .xls files to your email on the formatting issues.

    Thank you for all your continued help!



    ------------------------------
    Mark Sloan
    ------------------------------