BookmarkSubscribeRSS Feed
Calcite | Level 5


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?

Sample code:

   data  temp;

    set temp;


Fluorite | Level 6 DF
Fluorite | Level 6

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.

data one;

set two;


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!

Opal | Level 21

However, the behavior that DF describes can be controlled.  Take a look at:

Fluorite | Level 6 DF
Fluorite | Level 6

Ah - thanks Art!  I always forget about Modify and Update...

Calcite | Level 5

Thanks DJ / Art.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3 in conversation