Announcement

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

  • Error in post command: unknown function () post: above message corresponds to expression 1, variable



    I´m getting an error in my code when using post command but I don´t know why. The code is reproducible with auto dataset:


    Code:
    clear all
    
    tempfile locations
    tempname locat
    
    postfile `locat' str32(x1 x2 x3 x4) using `locations', replace
    
    sysuse auto
    
    gen population = 1
    
    gen domestico = 1 if foreign == 0
    gen externo = 1 if foreign == 1
    
    gen alto = 1 if gear_ratio <= 2
    gen bajo = 1 if gear_ratio > 2
    
    gen cost_h = 1 if price >= 10000
    gen cost_l = 1 if price < 10000
    
    
    local place "domestico externo"
    local gear_l "alto bajo"
    local cost "cost_h cost_l"
    
    
    foreach p of local place{
        foreach g of local gear_l{
            foreach c of local cost{
                    
            summ population  if `c'== 1 & `g' == 1 & `p' == 1
            local r = r(N)
            
            dis "`p'" "`g'" "`c'"  "`r'"
        
            post `locat' ("`c'")("`g'")("`p'")("`r'")
        
            }
        }        
    }
    Code:
    unknown function () post:  above message corresponds to expression 1, variable x1
    I´ve tried changing the type of variable in str32() for each variable but nothing works. Thanks
    Last edited by Luis Miguel García; 24 Apr 2023, 14:45.

  • #2
    The error message is, perhaps not misleading, but not really informative in this case. You need to put blank spaces between all the () expressions.

    Comment


    • #3
      Of course! I can't believe it. I was stuck with this a lot. Thanks Mr. Schechter.

      Comment

      Working...
      X