Hi everyone,

I am currently working on dataset wherein I have imported three datasets and for each of these I have to run a similar set of commands. For this, I first create tempfiles of each of these datasets; store them in a local and run a loop consisting of the common commands to run on the three datasets. The problem (which is a syntax error, most probably) is that when I try to save a new version of these tempfiles in the loop, I am unable to do so. I am sharing the code that I am using. It would be helpful if someone could let me know where I am going wrong in saving the new tempfiles inside the loop.

Code:
local file `a' `b' `c'  // creating a local to store tempfiles (which are created earlier in the code)
    
    foreach f in `file'{
        use `f', clear
        
        ren c_no c_id // running common commands
        ren p_no p_id
        
        replace c_id = subinstr(c_id , " ", "", .)
        
         tempfile `f'1 // saving new tempfiles to be used later in the code
        save ``f'1', replace
}
 
use `a1', clear
I am getting the following error when I run the loop:
Code:
 _: invalid name r(198);
Please let me know.

Thanks!