BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I can't find the missing school: Los_angeles has 2140 observations and KALA has 2141 observations. I tried using the following code to determine which observation is missing but can't.

DATA MATCH LOS_ANGELES KALA;
MERGE LOS_ANGELES (IN=L)
KALA (IN=K);
BY SCHNAME;
IF L AND NOT K THEN OUTPUT LOS_ANGELES;
IF NOT L AND K THEN OUTPUT KALA;
IF L AND K THEN OUTPUT MATCH;
RUN;
2 REPLIES 2
Andre
Obsidian | Level 7
Teresa,

you have made one mistake and think about the second remark
Andre

1) you are overwriting your source LOS_Angeles With your code replacing it!

see how to avoid this

[PRE]
25 DATA MATCH LOS K;
26 MERGE LOS_ANGELES (IN=L)
27 KALA (IN=K);
28 BY SCHNAME;
29 IF L AND NOT K THEN OUTPUT LOS;
30 IF NOT L AND K THEN OUTPUT K;
31 IF L AND K THEN OUTPUT MATCH;
32 RUN;

INFO: The variable one on data set WORK.LOS_ANGELES will be overwritten by data set WORK.KALA.
INFO: The variable two on data set WORK.LOS_ANGELES will be overwritten by data set WORK.KALA.
NOTE: There were 2 observations read from the data set WORK.LOS_ANGELES.
NOTE: There were 3 observations read from the data set WORK.KALA.
NOTE: The data set WORK.MATCH has 2 observations and 4 variables.
NOTE: The data set WORK.LOS has 0 observations and 4 variables.
NOTE: The data set WORK.K has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.01 seconds
[/PRE]


and second point
How are you sure there is only one record that differ?

This can also happen with this startpoint

[PRE]
Data los_angeles;
input schname $1. one two;
datalines;
A 12 36
B 15 25
;
data Kala;
input schname $1. one two three;
datalines;
D . 36 45
E 75 27 .
C 1 2 3
;
run;
Proc sort data=Kala; by schname;run;

INFO: The variable one on data set WORK.LOS_ANGELES will be overwritten by data set WORK.KALA.
INFO: The variable two on data set WORK.LOS_ANGELES will be overwritten by data set WORK.KALA.
NOTE: There were 2 observations read from the data set WORK.LOS_ANGELES.
NOTE: There were 3 observations read from the data set WORK.KALA.
NOTE: The data set WORK.MATCH has 0 observations and 4 variables.
NOTE: The data set WORK.LOS has 2 observations and 4 variables.
NOTE: The data set WORK.K has 3 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
[/PRE]
deleted_user
Not applicable
Thanks Andre! I appreciate your help.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1125 views
  • 0 likes
  • 2 in conversation