DATA Step, Macro, Functions and more

set only once

Reply
Super Contributor
Posts: 673

set only once

data hhs.hhs_combine_all(compress=yes);
set hhs.hhs_combine_all HHS_all;
description=upcase(description);
physician_name=upcase(physician_name);
ADDRESS_1=upcase(ADDRESS_1);
run;

How to load the above program to hhs.hhs_combine_all only one time.
I.e to avoid loading multiple times.
Valued Guide
Posts: 2,177

Re: set only once

run it once and it is run.
What runs it more than once?
Super Contributor
Super Contributor
Posts: 3,174

Re: set only once

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.

Scott Barry
SBBWorks, Inc.
Valued Guide
Posts: 2,177

Re: set only once

should it be proc append?
Super Contributor
Posts: 359

Re: set only once

No he is just UPCASING 3 variables. I have no idea what he is asking.
Super Contributor
Posts: 673

Re: set only once

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.
Contributor
Posts: 74

Re: set only once

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.
Super Contributor
Super Contributor
Posts: 3,174

Re: set only once

Posted in reply to abdullala
Also, you might receive more useful replies and assistance when you share the entire code piece and not just a convenient snippet.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 7 replies
  • 155 views
  • 0 likes
  • 5 in conversation