Announcement

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

  • macros in variable names

    hi,


    suppose i have a variables named x1 x2 x3 ....x2000 and had set the following local macro and forv loop (that obviously didnt work):

    local j 365
    forv i=366(365)2557{
    use x(`i'-`j') using abcd.dta
    }


    is it possible to specify the above -use- command by "subracting" macros to specify an x variable ? i tried a few formats but none worked.

    i m doing this to ultimately spit a data set "horizontally"

    thx


  • #2
    I will clarify my first post above:

    I m trying to split my data set "horizontally" . however , I m having problems.

    i ve tried variations of this so far:

    suppose i have a variables named x1 x2 x3 ....x2000 and had set the following local macro and forv loop (that obviously didnt work):

    l
    forv i=366(365)2557{
    local j 365
    use id x(`i'-`j')-x`i' using abcd.dta
    sreshape long x,i(id) j(day)
    save abcd`i'.dta
    }

    so for the first iteration, i=366, i want to use from the master dataset: the variable id and x1 to x366 using abcd.dta.


    is it possible to specify the above -use- command by "subracting" macros to specify an x variable ? i tried a few formats but none worked.

    any thoughts or alternative approaches?

    thx

    Comment


    • #3
      Previously asked, with at least one answer, at

      https://www.statalist.org/forums/for...01075-sreshape

      Comment

      Working...
      X