Announcement

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

  • using input in stata for file name

    Hi All,
    I am now trying to use multiple file names into data.

    clear
    global f "D:\data_science\myr\raw\image"
    *ssc install fs

    local jpg : dir "$f" files "*.jpg"
    di `jpg'

    foreach name in `jpg' {

    input x
    `name'
    end
    }

    When I do these codes, I got the error

    . foreach name in `jpg' {
    2.
    . input x
    3. `name'
    4. end
    --Break--
    r(1);


  • #2
    Hi All ,
    I got the solution

    clear
    set trace on
    global f "D:\data_science\myr\raw\image"


    local jpg : dir "$f" files "*.jpg"
    di `jpg'
    local j=1

    gen var1=""

    foreach var in `jpg'{

    set obs `j'
    replace var1="`var'" in `j'
    local ++j
    }

    Comment

    Working...
    X