Hi all,
I am trying to create a loop to run across two different files "PSQ_A" and "PSQ_B".
I want the loop to open each file and run the function 'describe'. I want to then generate a new variable 'Clinic' where the value is 'A' for file "PSQ_A" and 'B' for file "PSQ_B".
I have thought about using command 'forvalues', but I can't seem to get this to work.
Code:
forvalues i=A/B {
use PSQ_`i', clear
describe
gen Clinic=`i'
}
However I get invalid syntax.. Is this the correct command to use over multiple files?
I am trying to create a loop to run across two different files "PSQ_A" and "PSQ_B".
I want the loop to open each file and run the function 'describe'. I want to then generate a new variable 'Clinic' where the value is 'A' for file "PSQ_A" and 'B' for file "PSQ_B".
I have thought about using command 'forvalues', but I can't seem to get this to work.
Code:
forvalues i=A/B {
use PSQ_`i', clear
describe
gen Clinic=`i'
}
However I get invalid syntax.. Is this the correct command to use over multiple files?

Comment