Announcement

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

  • Help exporting to excel

    Hi everyone, I am previously an R-user and finding the functionality of STATA frustrating. I want to output a large table into Excel. The table calculates means and frequencies of age for each postcode area. I have written the following code to run the table and capture it as a matrix, and then export, but my first line of code will not work. Please help.

    capture quietly table postcode, contents(freq mean age median age min age max age), matcell(X)
    capture quietly matrix list X
    putexcel set "C:\PROJECT\means.xlsx", sheet("age") modify
    capture putexcel A1=matrix(X)
    capture matrix drop X

  • #2
    I don't think that -table- has that -matcell()- option; -tabulate- does, but it won't provide the statistics that you're seeking. Maybe take a look at -tabstats- or -statsby-.

    Actually, I'd use -collapse- and -export excel-.

    Comment


    • #3
      You can explore the command asdoc.

      Comment


      • #4
        I believe you can do this with - putexcel - command. Please read this text.
        Best regards,

        Marcos

        Comment


        • #5
          Dear Stata-enthusiasts,

          I have been searching a way to post a new question/post. But failed to understand how this works.

          Suppose, a list of Facilities having info on their country, states, Ownership (Privet or Govt) and some binary responses to questions whether the facilty has Toilet, canteen.......

          I am new to looping and exporting in excel. So trying to export two-by-two table between segregated categories of facilities and responses of the response variables.
          Facility ID Country State Facility Type Facility Ownership Toilet Waste bins Canteen Water
          908 BD a b x 1 1 0 1
          909 BD a b x 0 1 0 1
          910 BD g b x . 1 1 1
          911 BD g a x 1 1 0 0
          912 BD g c x . . . 1
          913 BD c c x 1 1 1 .
          914 USA n c x 1 1 1 1
          100 USA n d x . 0 1 1
          111 USA n d x . 1 0 1
          122 USA e d x 1 1 1 1
          133 USA e d y 0 1 . 0
          144 USA f a y 1 0 1 1
          155 USA f c y 0 0 0 0
          166 UK b c y 1 1 1 1
          177 UK b c y 1 0 1 0
          188 UK b c y 1 1 1 1
          199 UK r b y 0 0 1 .
          210 UK r b y 1 1 1 1
          221 UK r b y 1 0 0 0
          232 UK r b y 1 1 1 1
          243 UK r a y . 0 0 .
          254 IND u a y 1 0 1 1
          265 IND u a x 1 1 0 .
          276 IND u c x . 1 1 .
          287 IND u c x 0 0 . 1
          298 IND w c x 0 1 1 .
          309 IND w a y 1 . 0 1
          320 IND w a x 0 1 1 1
          331 IND w a y 0 . 1 0
          342 IND w c x 0 1 1 1
          353 IND y c x 1 1 0 .
          364 IND y c x 1 0 1 1
          375 IND y 3 y 0 1 1 0
          386 BEL i d y 1 0 1 1
          397 BEL i d y 1 . 1 1
          408 BEL i d y 1 1 0 1
          419 BEL q d 2 1 . . 1
          430 BEL q a y 1 1 . 1
          441 BEL q a y 1 1 . 1
          I have tried to follow threads in this forum to come up with a loop code, but can not brng together the results in each rows of the same excel sheet
          Toilet Waste bins Canteen Water Number of Facilities
          Country
          BD % % % % row total count
          USA % % % % row total count
          UK % % % % row total count
          IND % % % % row total count
          BEL % % % % row total count
          States
          a % % % % row total count
          g % % % % row total count
          c % % % % row total count
          n % % % % row total count
          e % % % % row total count
          f % % % % row total count
          b % % % % row total count
          r % % % % row total count
          u % % % % row total count
          w % % % % row total count
          y % % % % row total count
          i % % % % row total count
          q % % % % row total count
          Facility Type
          a % % % % row total count
          b % % % % row total count
          c % % % % row total count
          d % % % % row total count
          Faciltiy Ownership
          x % % % % row total count
          y % % % % row total count
          Overall % % % % row total count
          Last edited by Mahmoodur Rahman; 10 Sep 2019, 01:05.

          Comment

          Working...
          X