Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error using -fre- and strange format of variable

    After having exported data from LimeSurvey into a binary .sav (SPSS) data file and importing the file into Stata with -import spss-, if I run the .ado-program -fre- (from SSC) to display a frequency table of a variable I receive the error message
    Code:
                   sprintf():  3001  incorrect number of arguments
               fre_sprintf():     -  function returned error
     fre_display_or_export():     -  function returned error
                     <istmt>:     -  function returned error
    (the command -tab1- produces no error). The variable type is byte, but if I list the values of that variable they are shown as
    Code:
    . list lastpage if lastpage < 30
    
         +----------+
         | lastpage |
         |----------|
     21. |  0.0e+00 |
     88. |  1.0e+00 |
     95. |  1.0e+00 |
    105. |  2.8e+01 |
    120. |  0.0e+00 |
         |----------|
    146. |  1.0e+00 |
    154. |  1.4e+01 |
    155. |  1.3e+01 |
    176. | -1.0e+00 |
    209. |  0.0e+00 |
         +----------+
    The format of the variable in the variable window is shown as "10.0g" (not as "%10.0g"!). After running the command
    Code:
    format lastpage %10.0g
    the -list- command displays the values as expected and -fre- runs without error:
    Code:
    . list lastpage if lastpage < 30
    
         +----------+
         | lastpage |
         |----------|
     21. |        0 |
     88. |        1 |
     95. |        1 |
    105. |       28 |
    120. |        0 |
         |----------|
    146. |        1 |
    154. |       14 |
    155. |       13 |
    176. |       -1 |
    209. |        0 |
         +----------+
    
    . fre lastpage if lastpage < 30
    
    lastpage -- Letzte Seite
    -----------------------------------------------------------
                  |      Freq.    Percent      Valid       Cum.
    --------------+--------------------------------------------
    Valid   -1    |          1      10.00      10.00      10.00
            0     |          3      30.00      30.00      40.00
            1     |          3      30.00      30.00      70.00
            13    |          1      10.00      10.00      80.00
            14    |          1      10.00      10.00      90.00
            28    |          1      10.00      10.00     100.00
            Total |         10     100.00     100.00           
    -----------------------------------------------------------
    Any idea why this happens and how to solve the issue (except the work-around of using -format- to avoid the problem)?

  • #2
    I have no clue* (yet) why this problem occurs. But, after reading

    Originally posted by Dirk Enzmann View Post
    The format of the variable in the variable window is shown as "10.0g" (not as "%10.0g"!).
    I get the impression that the problem is probably with import spss not with fre. The latter merely exposes a problem: an invalid format, which the former should arguably not produce.


    * Edit

    OK, I guess I got it.

    fre.ado contains lines of the form

    Code:
    fre_sprintf(vals, st_varformat(st_local("varlist")))
    fre_sprintf() calls sprintf(). We can replicate the problem:

    Code:
    . mata : sprintf("%10.0g", 42)
              42
    
    . mata : sprintf("10.0g", 42)
                   sprintf():  3001  incorrect number of arguments
                     <istmt>:     -  function returned error
    r(3001);
    As I have indicated above, the problem should be fixed in import spss, which should not produce invalid display formats.
    Last edited by daniel klein; 07 Jan 2022, 12:08.

    Comment


    • #3
      Thanks Daniel, I will notify Stata Technical Support.

      Comment


      • #4
        Can you please send the SPSS file to [email protected] so that I may track down the problem?

        Comment

        Working...
        X