BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

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

4 REPLIES 4
LinusH
Tourmaline | Level 20

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
robertrao
Quartz | Level 8

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?????

robertrao
Quartz | Level 8

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

LinusH
Tourmaline | Level 20

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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