Help using Base SAS procedures

Same dataset referenced in output and input

Reply
New Contributor
Posts: 4

Same dataset referenced in output and input

Hi,

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;

   run;

Frequent Contributor
Frequent Contributor
Posts: 94

Same dataset referenced in output and input

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;

run;

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!

Esteemed Advisor
Posts: 7,091

Same dataset referenced in output and input

However, the behavior that DF describes can be controlled.  Take a look at: http://support.sas.com/techsup/technote/ts250.html

Frequent Contributor
Frequent Contributor
Posts: 94

Same dataset referenced in output and input

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

New Contributor
Posts: 4

Same dataset referenced in output and input

Thanks DJ / Art.

Ask a Question
Discussion stats
  • 4 replies
  • 89 views
  • 0 likes
  • 3 in conversation