DATA Step, Macro, Functions and more

merge

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

merge

The following SAS program is submitted:


libname temp ‘SAS data library’;
data temp.sales;
merge temp.sales
work.receipt;
by names;
run;
The input data files are sorted by the NAMES variable:

 

Happen to see this question, so is it okay to have same name for SAS data set that is referenced for both read
and write operations??


Accepted Solutions
Solution
‎09-28-2017 11:46 AM
Super User
Posts: 9,548

Re: merge

[ Edited ]

You can do it, which does not mean you should. If you have an error, you need to recreate the dataset from its original source(s).

 

PS when you create dataset xxx, SAS writes to a file named xxx.sas7bdat.lck. Once the step has finished, that file is renamed to xxx.sas7bdat. If a file with that name already exists, it is deleted first.

If an error (that SAS detects!) happened, and xxx.sas7bdat already exists, no rename is done, the new file is deleted, and the original kept. But that does not protect you from a logical error that is not detected by SAS.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Super Contributor
Posts: 333

Re: merge

Yes!

Smiley Happy

Solution
‎09-28-2017 11:46 AM
Super User
Posts: 9,548

Re: merge

[ Edited ]

You can do it, which does not mean you should. If you have an error, you need to recreate the dataset from its original source(s).

 

PS when you create dataset xxx, SAS writes to a file named xxx.sas7bdat.lck. Once the step has finished, that file is renamed to xxx.sas7bdat. If a file with that name already exists, it is deleted first.

If an error (that SAS detects!) happened, and xxx.sas7bdat already exists, no rename is done, the new file is deleted, and the original kept. But that does not protect you from a logical error that is not detected by SAS.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 119 views
  • 0 likes
  • 3 in conversation