Announcement

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

  • How to export list/table to excel with blank row as group separator

    Hello,
    Hoping someone has a hack to insert a blank row as a group separator when I export a list to excel.

    An example

    Code:
    sysuse auto, clear
    bys rep78 : keep if _n < 4
    l rep78 price, sepby(rep78) noobs
    If I copy and paste the above result, as a table, to excel, I get

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	5.6 KB
ID:	1519437


    Any idea how I can do without copy and paste (for large tables)

    Thanks in advance

    Ronnie
    010100100110111101101110011011100110100101100101

  • #2
    Try this:

    Code:
    sysuse auto, clear
    bys rep78 : keep if _n < 4
    l rep78 price, sepby(rep78) noobs
    
    egen seq=seq(), by(rep78)
    expand 2 if seq==1, generate(blankrow)
    sort rep78 blankrow
    
    replace price=. if blankrow==1
    l rep78 price blankrow, sepby(rep78) noobs
    
    replace rep78=. if blankrow==1
    l rep78 price, noobs separator(0)
    Last edited by Jenny Williams; 07 Oct 2019, 21:11.

    Comment


    • #3
      Many thanks, Jenny.


      Ronnie
      010100100110111101101110011011100110100101100101

      Comment

      Working...
      X