Announcement

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

  • exporting results from "fre" to excel with putexcel

    Hello all,

    I hope this message finds you well!

    I am looking for an efficient way to output the results from several computation of the user written command "fre" by Ben Jen into excel. I did not come across examples that show how to use putexcel with fre. Do either of you have any suggestions? The below code represents 10% of how many times I am computing "fre" and I do not want to manually have to type in each value. Any recommendations or suggestions will be very helpful.

    Code:
    fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number==1
    by country, sort: fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number==1
    by country, sort: fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag6
    fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag6
    by country, sort: fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag12
    fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag12
    by country, sort: fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag18
    fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag18
    by country, sort: fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag24
    fre hccat stuntingcat wastingcat weightcat anemia muaccat ///
    if screening_number!=1 & screening_number==flag24

    Best wishes,
    Patrick

  • #2
    I share your enthusiasm for the format of the output from -fre-. While -fre- save some results to a matrix, which could be output with -putexcel-, those results (see -return list- for -fre-) are in a bare-bones format. I'd suggest insteading exploring the -using- option of -fre- , with -tab- and -append- to output tables to a tab-separated file, which will import nicely into Excel.
    Code:
    foreach v of varlist hccat stuntingcat wastingcat weightcat anemia muaccat {
       fre `v' using "YourFile.tab" if screening_number ==1, tab append
    }

    Comment


    • #3
      Hello Mike,

      Thank you for your recommendation. Do I need a special software to open a .tab file? and how do I import it to Excel?

      I have a Mac and I can't find a way to import the file to Excel.

      Thank you
      Patrick

      Comment


      • #4
        Never mind my last question, for some reason my Excel version wasn't reading/importing .tab files and after multiple attempts it is now reading it!

        Thanks again for the recommendation.
        I do have one remaining question is it possible to change the layout of the output? for example in the below code I would want to include countries next to each other by column and only output the percentage including missing values.
        Code:
         
         foreach v of varlist hccat stuntingcat wastingcat weightcat anemia muaccat {    by country,sort: fre `v' using "YourFile.tab" if screening_number ==1, tab append }
        Thank you
        Patrick

        Comment


        • #5
          As to whether -fre- can itself output only the percentages, including missing values, you'd want to read the -help- documentation for -fre- in detail and see if such options exist for -fre-. I can't think of any easy way to put the countries next to each other by column. I suppose you might output countries to different files, and then append them columnwise in Excel. (I'm not much of an Excel user; that might not be possible.)

          Comment

          Working...
          X