Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65522

If in foreach

$
0
0
Good day all,

I have three files named A B C and four variables named time, timeA, timeB and timeC.

I regress variables X Y and Z for file A with time variable timeA, X Y and Z for file B with time variable timeB and X Y and Z for file C with time variable timeC

Stata is indicating that my if command is not correct, that 'A' is not found.

Does anyone know what I'm doing wrong in this syntax?

Code:
foreach period in A B C{
    clear all
    use "C:\`period'.dta"
    replace time=timeA if `period'=="A"
    replace time=timeB if `period'=="B"
    replace time=timeC if `period'=="C"
    foreach var in X Y Z{
        reg diff `var' time growth size
    }
}

Viewing all articles
Browse latest Browse all 65522

Trending Articles