Hello!
I have a feeling this question is a bit odd (and originates from me being an Excel user primarily - shame on me), but anyways:
In order to do corrections of my dataset, I have written down a number of commands manually in a file somewhat like this:
i command
2 command1
4 command2
5 command3
7 command4
9 command5
Where i is an identifier that creates a link to my original dataset.
I would now like to create a function that allows me to loop through consecutive values of, let's say x, and if the value of x equals the value of i, it should execute the command.
So something like:
Which of course does not work, because it will return an "invalid command" error.
I hope this is not too far off, but in my particular case it would be extremely helpful, because the commands are actually SQL requests which pull a dataset and in order to save this correctly I would like to use local macros I set up earlier in my code.
Looking forward to hear your ideas!
I have a feeling this question is a bit odd (and originates from me being an Excel user primarily - shame on me), but anyways:
In order to do corrections of my dataset, I have written down a number of commands manually in a file somewhat like this:
i command
2 command1
4 command2
5 command3
7 command4
9 command5
Where i is an identifier that creates a link to my original dataset.
I would now like to create a function that allows me to loop through consecutive values of, let's say x, and if the value of x equals the value of i, it should execute the command.
So something like:
Code:
forvalues x = 1(1)10 { if `x' = i[`x'] { command[`x'] } }
I hope this is not too far off, but in my particular case it would be extremely helpful, because the commands are actually SQL requests which pull a dataset and in order to save this correctly I would like to use local macros I set up earlier in my code.
Looking forward to hear your ideas!
Comment