Hello everyone! I need to use a for-loop to iterate through about 300 excel sheets that follow a pattern where every 3 sheets covers a year, and the three sheets are for male, female, and total data. I need to use 2 local macros as count variables to keep track of the two identifying features of each excel sheet. However, I have run into issues, and after testing basic output in the command window, that you can see below, I am failing to understand Stata's logic:
. local x = 1
. display `x'
1
. local y = 5
. display `y'
5
. if `y' == 5 { local x = `x' + 1 }
. display `x'
1
I want Stata to be increasing local macro x to 2 if local macro y is equal to 3 here. It runs the if command I have set up without error, but does not actually update x. Can someone tell me how to have Stata check for the value of a local macro and update another or the same local macro, or run other commands, accordingly? Thank you very much for your time and help!
. local x = 1
. display `x'
1
. local y = 5
. display `y'
5
. if `y' == 5 { local x = `x' + 1 }
. display `x'
1
I want Stata to be increasing local macro x to 2 if local macro y is equal to 3 here. It runs the if command I have set up without error, but does not actually update x. Can someone tell me how to have Stata check for the value of a local macro and update another or the same local macro, or run other commands, accordingly? Thank you very much for your time and help!
Comment