Announcement

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

  • Putexcel command works on one computer but does not work on another computer (same OS Server 2008 R2 and same version of Stata (14))

    I have a user that gets this on one server. On another server it works correctly. . putexcel A1=("Poverty and SN Table") using allpovtest, replace //TITLE
    using not allowed
    r(101);

    We updated the server with the issue to 14.1 but that did not help. Both servers are Windows 2008 R2 and Stata 14 Any ideas?

    Thanks very much!

    Mary Anne

  • #2
    See http://www.stata.com/help.cgi?putexcel

    In current Statas, using is indeed not allowed. You must specify the filename separately.

    http://www.stata.com/help.cgi?whatsnew explains that 14.1 includes this change:
    23. putexcel has a greatly simplified syntax and a more intuitive dialog.
    http://www.stata.com/help.cgi?version explains that the old syntax can be used under version control.



    Comment


    • #3
      It did not work before we updated to 14.1 either so something is wrong with the one server which is what I was trying to determine but can you give me the correct syntax to give my user? I guess I can email Stata support since the command above worked in 14 on one server with everything the same as the other server but on the other server it threw the above error while at 14 before being updated to 14.1. We then updated to 14.1 in case that would fix the issue however so if we decide to stay with that update my user will need to use the new syntax, I understand. I am in IT so I handle the app, it's issues and installs etc. but not the commands etc. I would be so grateful but I understand if it is too much to ask. Thanks!!
      Last edited by MaryAnne Rardin; 04 Nov 2015, 17:35.

      Comment


      • #4
        There are just three things to tell your users:

        1. They must read the help for the version they are using.

        2. The syntax changed from 14 to 14.1. So, whatever worked in 14 will need to be rewritten for 14.1.

        3. There is a way round #2, to use version control.

        In practice users knowledgeable and experienced enough to exploit #2 will not be bugging you. They will have worked this out, so your list of three things reduces to two.

        In your example the syntax

        Code:
        putexcel A1=("Poverty and SN Table") using allpovtest, replace
        will not work in 14.1 which is why updating will not solve that. At this instant I am unable to access the old syntax to say whether it will work in 14.

        If puzzles remain I strongly recommend a dialog[ue] with StataCorp technical support.

        Comment


        • #5
          See also the concurrent thread http://www.statalist.org/forums/foru...ng-not-allowed

          Comment


          • #6
            Please ignore that I mentioned 14.1 as that was only a test. There are two environments exactly the same server 2008 r2 and both Stata 14 not Stata 14.1. On one server the command works and on the other server the command does not work. I am getting to an application issue not a command issue. I am also contacting Stata support. From reading other posts I don't see a lot about application issues as opposed to syntax, command etc. issues. This is most likely a software issue...

            Comment


            • #7
              I don't know what it is but once I see that something works on one computer but not another I know that technical support need to step in and that they will asking you for lots of details.

              Comment


              • #8
                To preserve the old putexcel syntax you can add a version 14.0 at the top of your do-file. For example,

                Code:
                . version 14.0
                
                . putexcel A1=("Poverty and SN Table") using allpovtest, replace
                file allpovtest.xlsx saved
                If you don't add the version command in your do-file you will get a 101 error if you add using.

                Code:
                . version 14.1
                
                . putexcel A1=("Poverty and SN Table") using allpovtest, replace
                using not allowed
                r(101);
                The syntax of putexcel was changed so that you don’t have to specify the file name for each putexcel command. For example,

                Code:
                . version 14.1
                
                . putexcel set allpovtest, replace
                
                . putexcel A1="Poverty and SN Table"
                file allpovtest.xlsx saved
                
                . putexcel B1="SN"
                file allpovtest.xlsx saved
                
                . putexcel C1="Poverty"
                file allpovtest.xlsx saved
                Last edited by Kevin Crow (StataCorp); 05 Nov 2015, 11:43.

                Comment


                • #9
                  To follow up on this. I've encountered a similar problem with "putexcel" as the original post using Stata 15 and the updated putexcel code.

                  In my case I can run the same code (see snippet below) with Stata 15 on a linux machine without issue, however, the same code fails to run on various windows machines. What's more interesting is that on the windows machine(s) Stata stops at different places seemingly without reason.

                  The code is in a loop, but it is written such that it will display different text for each iteration of the loop. As shown in the pictures, using a windows based version of Stata results in stoppages at different stages of the loop at what seems to be random. The pictures are from running the same code over and over and result in different outcomes...

                  Any assistance in debugging this is welcome! ... I didn't show the linux output because it runs to completion without issue, creating the excel file with the appropriate sheets with correct names, etc.

                  Thank you in advance for any help.




                  Code:
                  ***********************************************************************************
                  ***                            Making Frequency Tables                            ***
                  ***********************************************************************************
                  *** Frequencies of obs across cohorts for NHW  for both male and female 
                  forval race = 1(1)2 {
                      if `race' == 1 {
                          local r = "NHW"    
                      }
                      if `race' == 2 {
                          local r = "NHB"    
                      }
                      di as error "Counts `r'"
                      qui putexcel set "`results'/HRS_Sample_table", replace sheet(`r', replace) 
                      
                      qui putexcel A1 = "All `r' HRS" 
                      qui putexcel B1 = "Cohort"
                      qui putexcel B2 = "AHEAD"
                      qui putexcel B3 = "CODA"
                      qui putexcel B4 = "HRS"
                      qui putexcel B5 = "War Babies"
                      qui putexcel B6 = "Early Boomers"
                      qui putexcel B7 = "Mid Boomers"
                  
                      qui putexcel C1 = "N"
                      qui putexcel D1 = "% w/Social Origins"
                      qui putexcel E1 = "% w/PGS"
                      qui putexcel F1 = "% w/Social Origins & PGS"
                      di as text "All `r' HRS"
                      forval i = 1(1)6 {
                          local j = `i' + 1
                          qui count if racohbyr == `i' & raracem == `race' 
                          local total_hrs_`i' = `r(N)'
                          qui count if racohbyr == `i' & raracem == `race' & SOBWD != . 
                          local so_hrs_`i' = `r(N)'
                          qui count if racohbyr == `i' & raracem == `race' & zrpgsEA3 != . 
                          local pgs_hrs_`i' = `r(N)'
                          qui count if racohbyr == `i' & raracem == `race' & SOBWD != . & zrpgsEA3 != . 
                          local sopgs_hrs_`i' = `r(N)'
                  
                          qui putexcel C`j' = `total_hrs_`i''
                          qui putexcel D`j' = `so_hrs_`i''/`total_hrs_`i'' , nformat(percent_d2)
                          qui putexcel E`j' = `pgs_hrs_`i''/`total_hrs_`i'' , nformat(percent_d2)
                          qui putexcel F`j' = `sopgs_hrs_`i''/`total_hrs_`i'' , nformat(percent_d2)
                      }
                      qui putexcel A10 = "HRS `r' LTHS"
                      qui putexcel B10 = "Cohort"
                      qui putexcel B11 = "AHEAD"
                      qui putexcel B12 = "CODA"
                      qui putexcel B13 = "HRS"
                      qui putexcel B14 = "War Babies"
                      qui putexcel B15 = "Early Boomers"
                      qui putexcel B16 = "Mid Boomers"
                      
                      qui putexcel C10 = "Full Sample"
                      qui putexcel D10 = "Social Origins Sample"
                      qui putexcel E10 = "PGS Sample"
                      qui putexcel F10 = "Social Origins & PGS Sample"
                      di as text "HRS `r' LTHS"
                      forval i = 1(1)6 {
                          local j = `i' + 10
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' 
                          local total_lths_`i' = `r(N)'
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & SOBWD != . 
                          local so_lths_`i' = `r(N)'
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & zrpgsEA3 != . 
                          local pgs_lths_`i' = `r(N)'
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & SOBWD != . & zrpgsEA3 != . 
                          local sopgs_lths_`i' = `r(N)'
                  
                          qui putexcel C`j' = `total_lths_`i''/`total_hrs_`i'' , nformat(percent_d2)
                          qui putexcel D`j' = `so_lths_`i''/`so_hrs_`i'' , nformat(percent_d2)
                          qui putexcel E`j' = `pgs_lths_`i''/`pgs_hrs_`i'' , nformat(percent_d2)
                          qui putexcel F`j' = `sopgs_lths_`i''/`sopgs_hrs_`i'' , nformat(percent_d2)
                      }
                      qui putexcel A20 = "All GWAS eligible `r'"
                      qui putexcel B20 = "Cohort"
                      qui putexcel B21 = "AHEAD"
                      qui putexcel B22 = "CODA"
                      qui putexcel B23 = "HRS"
                      qui putexcel B24 = "War Babies"
                      qui putexcel B25 = "Early Boomers"
                      qui putexcel B26 = "Mid Boomers"
                      qui putexcel C20 = "N"
                      qui putexcel D20 = "% w/Social Origins"
                      qui putexcel E20 = "% w/PGS"
                      qui putexcel F20 = "% w/Social Origins & PGS"
                      di as text "All `r' HRS"
                      forval i = 1(1)6 {
                          local j = `i' + 20
                          qui count if racohbyr == `i' & raracem == `race' & (inw8 == 1 | inw9 == 1)
                          local total_gwas_`i' = `r(N)'
                          qui count if racohbyr == `i' & raracem == `race' & SOBWD != . & (inw8 == 1 | inw9 == 1)
                          local so_gwas_`i' = `r(N)'
                          qui count if racohbyr == `i' & raracem == `race' & zrpgsEA3 != . & (inw8 == 1 | inw9 == 1)
                          local pgs_gwas_`i' = `r(N)'
                          qui count if racohbyr == `i' & raracem == `race' & SOBWD != . & zrpgsEA3 != . & (inw8 == 1 | inw9 == 1)
                          local sopgs_gwas_`i' = `r(N)'
                  
                          qui putexcel C`j' = `total_gwas_`i''
                          qui putexcel D`j' = `so_gwas_`i''/`total_gwas_`i'' , nformat(percent_d2)
                          qui putexcel E`j' = `pgs_gwas_`i''/`total_gwas_`i'' , nformat(percent_d2)
                          qui putexcel F`j' = `sopgs_gwas_`i''/`total_gwas_`i'' , nformat(percent_d2)
                      }
                      qui putexcel A30 = "GWAS eligible `r' LTHS"
                      qui putexcel B30 = "Cohort"
                      qui putexcel B31 = "AHEAD"
                      qui putexcel B32 = "CODA"
                      qui putexcel B33 = "HRS"
                      qui putexcel B34 = "War Babies"
                      qui putexcel B35 = "Early Boomers"
                      qui putexcel B36 = "Mid Boomers"
                      qui putexcel C30 = "Full Sample"
                      qui putexcel D30 = "Social Origins Sample"
                      qui putexcel E30 = "PGS Sample"
                      qui putexcel F30 = "Social Origins & PGS Sample"
                      di as text "HRS `r' LTHS"
                      forval i = 1(1)6 {
                          local j = `i' + 30
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & (inw8 == 1 | inw9 == 1)
                          local total_gwas_lths_`i' = `r(N)'
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & SOBWD != . & (inw8 == 1 | inw9 == 1)
                          local so_gwas_lths_`i' = `r(N)'
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & zrpgsEA3 != . & (inw8 == 1 | inw9 == 1)
                          local pgs_gwas_lths_`i' = `r(N)'
                          qui count if racohbyr == `i' & educ_lths == 1 & raracem == `race' & SOBWD != . & zrpgsEA3 != . & (inw8 == 1 | inw9 == 1)
                          local sopgs_gwas_lths_`i' = `r(N)'
                  
                          qui putexcel C`j' = `total_gwas_lths_`i''/`total_gwas_`i'' , nformat(percent_d2)
                          qui putexcel D`j' = `so_gwas_lths_`i''/`so_gwas_`i'' , nformat(percent_d2)
                          qui putexcel E`j' = `pgs_gwas_lths_`i''/`pgs_gwas_`i'' , nformat(percent_d2)
                          qui putexcel F`j' = `sopgs_gwas_lths_`i''/`sopgs_gwas_`i'' , nformat(percent_d2)
                      }
                      qui putexcel close 
                  }


                  Stata Output using the same code run one attempt right after the other

                  Attempt #1
                  Click image for larger version

Name:	PutexcelExit_01.PNG
Views:	2
Size:	7.2 KB
ID:	1458002


                  Attempt #2
                  Click image for larger version

Name:	PutexcelExit_02.PNG
Views:	1
Size:	5.9 KB
ID:	1458003


                  Attempt #3
                  Click image for larger version

Name:	PutexcelExit_03.PNG
Views:	1
Size:	7.9 KB
ID:	1458004
                  Attached Files

                  Comment


                  • #10
                    I can answer this one! Every time putexcel writes to an excel file, it opens the file, writes to it, saves to disk and then closes it. When you have a loop like the one above, sometimes Stata will try to output results before the system has registered that it has closed (the error you are getting is because Stata thinks you are trying to write to a file that is open/read-only). If you add the "open" option to your putexcel set statement it will resolve the issue - it won't save the file to disk until it gets to putexcel close.

                    Comment

                    Working...
                    X