Announcement

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

  • Variable name and variable label are not shown after the execution of "putexcel" command

    My data



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int id byte educ str6 date str2 state float(regprc ecoprc) byte(inseason hhsize male) int faminc byte age float(reglbs ecolbs) byte(numlt5 num5_17 num18_64 numgt64)
    10002 16 "111597" "SD" 1.19 1.19 1 4 0  45 43         2         2 0 1 3 0
    10004 16 "121897" "KS"  .59  .79 0 1 0  65 37         0         2 0 0 1 0
    10034 18 "111097" "MI"  .59  .99 1 3 0  65 44         0  2.666667 0 2 1 0
    10035 12 "111597" "TN"  .89 1.09 1 2 1  55 55         3         0 0 0 2 0
    10039 15 "122997" "NY"  .89 1.09 0 1 1  25 22         0         3 0 0 1 0
    10041 12 "112297" "WV"  .59  .79 1 4 0  15 34         0         3 0 2 2 0
    10046 14 "111597" "MI"  .59  .79 1 5 0  25 72         0         2 0 1 2 2
    10048 16 "122397" "VA"  .59  .59 0 4 0  45 38         0 1.6666666 0 2 2 0
    10050 17 "111697" "NY" 1.19 1.19 1 1 1 105 50         0        .5 0 0 1 0
    10057 12 "111697" "GA" 1.19 1.19 1 2 0  25 69         0 2.3333333 0 0 0 2
    10062 18 "110897" "NY"  .59  .79 1 3 0 130 37         0         3 1 0 2 0
    10066 16 "122397" "MI"  .59  .59 0 3 1 130 48         0         2 1 0 2 0
    10068 12 "111597" "OH" 1.19 1.39 1 5 0  45 36         0         4 0 3 2 0
    10078 13 "112397" "CA"  .59  .59 1 2 0  25 37         0 1.6666666 0 0 2 0
    10083 14 "112397" "CA"  .59  .59 1 1 0  65 56         0  2.666667 0 0 1 0
    10085  9 "111497" "CA"  .89  .89 1 5 1  15 36         4         0 2 1 2 0
    10086 13 "121497" "CA" 1.19 1.39 0 4 0  45 48         0         1 0 1 3 0
    10088 18 "110897" "CA"  .59  .99 1 2 0  85 71         5         0 0 0 0 2
    10091 16 "120797" "CA"  .89 1.09 0 2 0 250 45         5         0 0 0 2 0
    10095 14 "112397" "TX" 1.19 1.39 1 5 0  85 47         0        10 0 3 2 0
    10096 18 "111097" "TX"  .59  .79 1 2 0 105 52         0         2 0 0 2 0
    10102 14 "111897" "TX"  .89  .89 1 3 0  45 35 2.3333333  .6666667 1 0 2 0
    10103 13 "110897" "AL"  .59  .99 1 3 0  25 25         3         0 1 1 1 0
    10110 13 "112097" "WI"  .89 1.29 1 2 0  45 66         2         0 0 0 0 2
    10111 12 "110897" "AL"  .59  .79 1 2 0 130 83         0         2 0 0 0 2
    10112 16 "110897" "IL"  .59  .99 1 3 0  95 41         0         3 0 2 1 0
    10113 13 "111597" "IL" 1.19 1.39 1 3 1  55 47         0         1 0 0 3 0
    10116 10 "111697" "KY" 1.19 1.59 1 1 0  25 60       2.5         0 0 0 1 0
    10117 16 "111197" "ME"  .89  .89 1 4 0  65 43         0 1.3333334 0 2 2 0
    10118 16 "121597" "NY"  .59  .99 0 6 0  95 26         0  .6666667 3 1 2 0
    10122 16 "112397" "IN"  .89  .89 1 5 0  55 28         0         1 1 2 2 0
    10129 18 "112297" "MA"  .89  .89 1 1 0  55 49 1.6666666         0 0 0 1 0
    10131 16 "121397" "NY"  .59  .79 0 1 1  25 36  .6666667  .6666667 0 0 1 0
    10132 17 "111297" "RI"  .59  .79 1 2 1  65 62         2         2 0 0 1 1
    10133 12 "111597" "MD"  .89 1.09 1 1 0  55 37         0         2 0 0 1 0
    10136 13 "121897" "TN" 1.19 1.19 0 2 0  35 53         2         2 0 0 2 0
    10144 13 "111197" "NJ"  .89 1.09 1 2 1 105 52  2.666667         0 0 0 2 0
    10147 16 "111197" "SC"  .59  .79 1 4 0  85 29         0  3.333333 2 0 2 0
    10155 16 "121597" "FL" 1.19 1.39 0 1 0  35 72  .6666667         0 0 0 0 1
    10182 18 "112297" "IL"  .89 1.09 1 3 0  65 45         1         0 1 0 2 0
    10183 17 "111897" "IL" 1.19 1.19 1 2 0  55 49         0         1 0 0 2 0
    10190 17 "111697" "MN" 1.19 1.19 1 2 0  45 53         0         2 0 0 2 0
    10191 14 "110897" "IA"  .59  .99 1 5 0  95 52        10         3 1 2 2 0
    10195 13 "111597" "WI"  .59  .79 1 3 1  65 29         0         2 0 0 3 0
    10199 12 "111697" "TN" 1.19 1.59 1 3 0  45 57         1         0 0 0 2 1
    10203 12 "111197" "OH"  .59  .59 1 2 0  25 68         0         5 0 0 0 2
    10205 16 "111197" "NY"  .59  .99 1 1 0  45 65         0         1 0 0 0 1
    10207 16 "110897" "VA"  .59  .99 1 8 0 105 50         1         1 3 0 5 0
    10208 16 "112097" "FL"  .89  .89 1 2 0  35 81         0         2 0 0 0 2
    10220 14 "112097" "GA" 1.19 1.39 1 4 0  35 28        .5        .5 2 0 2 0
    10226 16 "111897" "FL" 1.19 1.59 1 2 0  45 77         0         5 0 0 0 2
    10229 16 "110897" "VT"  .59  .79 1 1 1  45 46         2         0 0 0 1 0
    10250 17 "112297" "CA"  .59  .59 1 2 1  45 31         0 1.6666666 0 0 2 0
    10259 12 "112397" "OK"  .89 1.09 1 7 0  15 35         3         0 0 3 2 2
    10262 12 "112597" "MN"  .89  .89 1 2 0  35 62         0         4 0 0 2 0
    10263 13 "111697" "MO"  .89 1.09 1 3 0  55 38 1.6666666         0 0 1 2 0
    10268 17 "111297" "FL"  .89  .89 1 3 1  45 69         0         2 0 0 1 2
    10270 18 "120697" "MN" 1.19 1.19 0 4 0  45 50         0 1.6666666 0 2 2 0
    10271 15 "111297" "TN"  .59  .79 1 3 0 175 35         0         2 1 0 2 0
    10274 17 "111697" "TX"  .89  .89 1 3 0  45 62       2.5        .5 0 0 3 0
    10276 17 "111697" "WI" 1.19 1.59 1 4 0  65 30         2         2 2 0 2 0
    10282 15 "111697" "IL"  .89  .89 1 1 0  75 49         1         0 0 0 1 0
    10283 15 "112197" "WI" 1.19 1.19 1 3 0  45 37         0 1.3333334 1 0 2 0
    10290 14 "122897" "NY" 1.19 1.39 0 4 1  75 40         5         0 0 2 2 0
    10293 12 "110997" "OH"  .59  .59 1 4 1  75 50         0         3 0 0 4 0
    10294 14 "112297" "NY"  .59  .79 1 3 1  55 30         2         2 1 0 2 0
    10301 16 "111197" "CT"  .59  .59 1 2 0 175 40         0         2 0 0 2 0
    10306 18 "110997" "GA"  .59  .79 1 4 1  85 22       1.5         0 0 0 4 0
    10307 12 "111197" "PA"  .59  .99 1 4 0  65 39         0         4 0 0 4 0
    10308 12 "10798"  "VA"  .59  .99 0 4 0  35 38         1         1 0 2 2 0
    10309 16 "10498"  "OH"  .89 1.29 0 3 0 130 42 1.3333334         0 0 0 2 1
    10310 16 "111697" "MD" 1.19 1.59 1 1 0  45 33         1         0 0 0 1 0
    10314 14 "111397" "VA"  .89 1.29 1 2 0  55 35         0         2 0 0 2 0
    10315 14 "111297" "OH"  .59  .99 1 3 0  35 26       2.5         0 0 1 2 0
    10330 13 "122397" "NV"  .89 1.09 0 4 0  25 49         0         1 0 1 3 0
    10345 14 "122097" "TX" 1.19 1.19 0 2 1  25 63        10         0 0 0 2 0
    10348 18 "111097" "MN"  .59  .79 1 2 0  45 61         0         5 0 0 2 0
    10350 16 "112097" "SD" 1.19 1.19 1 4 0  55 47         0 1.3333334 0 2 2 0
    10355 16 "10498"  "TX"  .89  .89 0 4 0  85 39         0         0 0 2 2 0
    10363 14 "112197" "TN" 1.19 1.39 1 4 1  45 35         0  3.333333 0 3 1 0
    10374 16 "111297" "NY"  .89 1.09 1 6 0  25 24  3.333333  3.333333 4 0 2 0
    10377 18 "111297" "NY"  .89 1.29 1 3 0  45 30         1       1.5 0 0 3 0
    10381 12 "111797" "FL" 1.19 1.19 1 3 0  35 42         0         5 0 1 2 0
    10382 12 "111397" "FL"  .89 1.29 1 4 1  45 26         0         2 2 0 2 0
    10386 15 "111597" "OH"  .89 1.09 1 2 0  35 80 1.3333334         0 0 0 0 2
    10388 12 "111897" "FL" 1.19 1.59 1 3 1  55 38         3         0 1 0 2 0
    10389 12 "110997" "GA"  .59  .79 1 3 1  25 52         0         3 0 0 3 0
    10390 13 "111297" "CT"  .89 1.29 1 1 1  15 75         2         0 0 0 0 1
    10392 14 "122797" "NY" 1.19 1.59 0 3 0  85 28         0 1.3333334 1 0 2 0
    10395 16 "111297" "GA"  .89 1.29 1 5 0  55 39         5         0 1 2 2 0
    10401 11 "111297" "IN"  .89 1.29 1 1 0  15 78         5         0 0 0 0 1
    10406 14 "111897" "ID" 1.19 1.59 1 3 0  25 46         0        .5 0 2 1 0
    10413 16 "111297" "CA"  .89 1.09 1 2 0  95 52         1         0 0 0 2 0
    10417 12 "112397" "CA"  .89  .89 1 5 0  45 22         0         2 1 0 4 0
    10421 14 "112397" "NV"  .59  .59 1 5 0  75 41         2         2 0 0 5 0
    10425 12 "111097" "TX"  .59  .59 1 4 1  25 33         0         4 0 3 1 0
    10428 12 "111597" "TX"  .89  .89 1 2 0  55 61         0         3 0 0 2 0
    10429 13 "112297" "LA"  .89  .89 1 4 1  55 39         0         2 0 2 2 0
    10430 12 "111897" "IL"  .89  .89 1 5 0  65 34  .6666667  .6666667 0 3 2 0
    10431 16 "111597" "FL"  .59  .99 1 5 0  35 35         6  .3333333 0 3 2 0
    end



    My Stata version 14.2

    My commands:




    putexcel set ex4,replace
    tabulate age male, matcell(freq) matrow(names)
    return list

    matrix list freq
    matrix list names

    putexcel A1=matrix(names) B1=matrix(freq)





    It did not any variable names. in addition, it showed only label of variable: age. ( See 1.JPG)



    Alternatively, I tried



    tab age male, missing matcell(stars)
    levelsof age, missing local(down)
    levelsof male, missing local(across)

    matrix rownames stars = `down'
    matrix colnames stars = `across'

    matrix list stars

    putexcel set ex4,replace


    putexcel A1=matrix(stars)



    In this case, no variable names and label were displayed ( see 2.JPG)


    Any suggestion? Thanks
    Attached Files

  • #2
    Change
    Code:
    putexcel A1=matrix(names) B1=matrix(freq)
    to
    Code:
    putexcel A1=matrix(names)
    putexcel B1=matrix(freq)
    The output for help putexcel does not suggest that more than one matrix can appear in a single putexcel command.

    Comment


    • #3
      Originally posted by William Lisowski View Post
      Change
      Code:
      putexcel A1=matrix(names) B1=matrix(freq)
      to
      Code:
      putexcel A1=matrix(names)
      putexcel B1=matrix(freq)
      The output for help putexcel does not suggest that more than one matrix can appear in a single putexcel command.
      Thanks a lot. But still no success!

      Comment


      • #4
        One common reason for the appearance of no change in an output dataset - your Excel workbook in this case - is that you've changed your Stata working directory since you first ran the command, so the corrected dataset is being created in a different location, and you are accidentally still looking at the original dataset.

        The easiest way to check this is to change the file name on the putexcel command. If it doesn't show up in the directory you've been looking in for your output, run a pwd command to tell you where it was written, and then look in that location for a your renamed Excel workbook. Open it and you should see names and not frequencies. And in the same location, you'll probably see the workbook you created earlier with the original name, now containing names and frequencies.

        Comment

        Working...
        X