Announcement

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

  • Local macro based on another local macro

    Hello I have a local macro containing values 10 20 30 40 50

    I want to create another local macro that contains the values based on this macro above but only for the first x values, so x= 4 this new macro would contain values 10 20 30 40.

    Code:
    local test 10 20 30 40 50 
    display "`test'"
    
    * create new macro based on previous macro values
    Please could you assist me. Thanks, Jad.

  • #2
    Code:
    local test 10 20 30 40 50
    local x 4
    
    local new_macro
    forvalues i = 1/`x' {
        local new_macro `new_macro' `:word `i' of `test''
    }
    
    display `"`new_macro'"'

    Comment


    • #3
      Also

      Code:
      local test 10 20 30 40 50 
      
      tokenize "`test'"
      
      local wanted `1' `2' `3' `4'

      Comment


      • #4
        Thanks!

        Comment

        Working...
        X