- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to merge two different datasets, keeping some variables of the second dataset.
I used the following code:
proc sort data = MO;
by n;
run;
proc sort data = TE;
by n;
run;
Data MOTE;
Merge MO (in=A) TE (in=B keep = n UltMes MesSEMReg);
by n;
If A;
run;
In the merged data set the variables UltMes MesSEMReg exist but they are empty.
Can you help me solving this problem?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry @ballardw and @Astounding
Thank you for your help.
I have misspecified the name of the second dataset. Correcting it, solves the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Since you are only keeping records that have matching values of N in the data set MO the most likely cause of "missing" values for those variables is that your data set TE does not have values when the N matches.
You can test this with:
Proc freq data=TE; tables n * (UltMes MesSEMReg) /list missing; run;
and look at the values of N in the MO data set and see what you have for UltMes and Messemreg for those in TE.
Next most likely
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Both variables UltMes and MesSEMReg of dataset TE have registers in all of the fields.
The problem is not that one you helpfully suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ramgouveia wrote:
Both variables UltMes and MesSEMReg of dataset TE have registers in all of the fields.
The problem is not that one you helpfully suggested.
Are you sure that you have any matches of the BY variable? The code you used would have no contribution from TE if there are no matching values of N.
Did you 1) actually run the Proc Freq code I suggested and 2) compare any of the N values from the Freq output with the MO data set?
Just looking at displayed values may not be sufficient. Formats can round values to appear the same and if N is character leading spaces or non-printable characters may be present that make them not equal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
By any chance, do these variables:
n UltMes MesSEMReg
already exist in the TO data set before you merge?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry @ballardw and @Astounding
Thank you for your help.
I have misspecified the name of the second dataset. Correcting it, solves the error.