From my perspective, the question is unclear, however from the SET statement, it appears that there is a file to be replaced by adding new observations to that same file. But of course, the first time the file that is named in both the DATA and SET statement will not exist. Maybe this is the question?
If true, the SAS OPTIONS NODSNFERR; can be set. And if you have a BY statement to order the observations, you will also need to set NOVNFERR and NOBYERR, as well.
This part of the code is the middle portion of a macro.There are situations,when I had to make changes to the code above or below this data step and so had to run the whole code again.in those situations hhs_all gets appended again resulting in duplicate values.
I dont know there is any way your code will work for that purpose. you will need to control when to append the other dataset.
approach 1: do all you need to do to the base dataset, and only append at the very end after all the repeating work are completed.
approach 2: use different dataset name after appending so the original does not get overwritten by appending.