Announcement

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

  • Looping specific cell before appending using xls2dta

    Hi Statalist,

    Any help to my appended files using xls2dta. I wanted to include data from specific cells to my appended dataset; like
    In cell F3 contains “form unique id”
    In cell F4 contains “name of in-charge”
    In celn V4 contains “year”
    In cell AE contains “city”

    Here’s my command.

    clear
    set more off
    cd "C:\Users\ AKAP 2023-12-05\2023 - 2024 SF1"
    xls2dta, gen (source) save("$temp") recursive replace : import excel "C:\Users\AKAP 2023-12-05\2023 - 2024 SF1", cellrange(A5) firstrow case(lower)
    local uniqueid = f[3]
    local name = f[4]
    local year = v[4]
    local city = ae[4]
    gen int uniqueid = "`uniqueid "
    gen str12 name = "`name"
    gen int year = "`year"
    gen int schoolid = "`schoolid'"
    xls2dta ,clear : append force

    also, I want to get rid of the “force” when appending the dataset

    Thank you in advance.
    CAPI Specialist
    Data Manager
Working...
X