Help using Base SAS procedures

Merge

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

Merge

Hi,

I have two datasets and am merging them.

I want to know what call missing is doing specifically here!!!!

After outputting why do we need to set them to missing again?????

We are not retaining the missing values and how does it affect the fresh records??????

I have the log shown as well!!

BASICALLY WE ARE NOT TELLING ANYWHERE IN THE CODE THAT SPECIFICALLY WE WANT THE NEXT RECORD TO HAVE THOSE VARIABLES SET TO MISSING!!!!!

data diag;

  input person diag ;

cards;

101  999

101  888

101  777

101  666

101  555

;

data proc ;

  input person proc;

cards;

101  111

101  222

101  333

;

data want ;

  merge diag proc;

  by person; 

  output;

  call missing(diag,proc);
  putlog _all_;

run;

101 diag=. proc=. FIRST.person=1 LAST.person=0 _ERROR_=0 _N_=1


101 diag=. proc=. FIRST.person=0 LAST.person=0 _ERROR_=0 _N_=2


101 diag=. proc=. FIRST.person=0 LAST.person=0 _ERROR_=0 _N_=3


101 diag=. proc=. FIRST.person=0 LAST.person=0 _ERROR_=0 _N_=4


101 diag=. proc=. FIRST.person=0 LAST.person=1 _ERROR_=0 _N_=5


Accepted Solutions
Solution
‎06-17-2013 12:35 PM
Super User
Posts: 5,431

Re: Merge

Posted in reply to robertrao

It was just a another word for djag and proc in your specific example. Call missing has generally nothing to do with BY.

Data never sleeps

View solution in original post


All Replies
Super User
Posts: 5,431

Re: Merge

Posted in reply to robertrao

Well, you should be able to see what the effect by looking in resulting dataset.

Since there are repeating records with the same by variable, the last record from the dataset with fewer records will stay in the PDV, kind of a implicit retain. Call missing will in this case set the non by variables to null after the first merging record.

What is the source of this situation? Merging data with repeated by variables in both tables are usually not seen as best practice!

Data never sleeps
Super Contributor
Posts: 1,041

Re: Merge

I get tthe right answer but wanted a clarification for the code...

Even if it is Many to Many I wanted to merge and not retain the previous value which SAS does Usually

So  after the first record is output.....the same record is set to missing for the specified variables.....Then brings the values in the second record plugs them in ......OUTPUTS...then sets the same to missing for those vars.......Brings the values from the third .and so on

Is that RIGHT?????

Super Contributor
Posts: 1,041

Re: Merge

Hi,

Could you also explain whats the meaning of "non by variables" in the below

"Call missing will in this case set the non by variables to null after the first merging record."

Thanks

Solution
‎06-17-2013 12:35 PM
Super User
Posts: 5,431

Re: Merge

Posted in reply to robertrao

It was just a another word for djag and proc in your specific example. Call missing has generally nothing to do with BY.

Data never sleeps
🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 253 views
  • 3 likes
  • 2 in conversation