08-24-2011 06:36 AM
I am new to SAS.I saw same dataset is referenced for both input and output.I want to understand what happens in the background.How sas handles the same sas dataset as input and output?
08-24-2011 09:11 AM
Basically, it starts off by reading in from the original dataset, but outputting to a temporary file. In your example this would be called "code.lck" and should appear in the same folder as the rest of your datasets (e.g. your WORK library).
Once the process is finished, assuming there were no errors, SAS deletes the original file (code.sas7bdat) and renames the temporary file to replace the original.
The same process happens when creating a new dataset for the first time, or overwriting an old one. E.g.
The "one.lck" file is created first, and if it already exists "one.sas7bdat" is deleted once the code finishes running.
If you're running code that takes long enough, you can see these files being created/deleted.
Hope that helps!