I want to compare two datasets and extract the matching observations to a new data set. For example,
I have two datasets, one from October and another from November, as follows.
Dataset October
visitor_id ctn visits
kjsjakd83 3243244234 1
sakdsadda 5432223442 2
jhk43242l 3243243244 1
iiiewdaja 9839422022 2
Dataset November
visitor_id ctn visits
kjsjakd83 3243244234 1
432hj4hj 3243243244 2
jhk43242l 3243243244 1
xfd3x424 2342344234 2
Now, I want to compare these datasets by CTN and extract all the observations from October dataset for which a matching CTN is found in November dataset. So, the extracted dataset must be as below.
Dataset Match
visitor_id ctn visits
kjsjakd83 3243244234 1
jhk43242l 3243243244 1
How can I do this in SAS?
proc sql; create table final as select Distinct a.CTN, a.visits from Nov a inner join Oct b on b.CTN = a.CTN; quit;
– anurag choubey