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

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.

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
  • 2 replies
  • 928 views
  • 0 likes
  • 2 in conversation