Hello!
I am currently working on performing a match-merge across four data sets. Each observation should include a unique SSN; however one dataset records four observations per one SSN. How would I go about including only the last recorded observation for each unique SSN to my final match-merged dataset?
The observations for the data set in question would be structured similarly to:
111-11-1111 ...
111-11-1111 ...
111-11-1111 ...
111-11-1111 ...
222-22-2222 ...
222-22-2222 ...
222-22-2222 ...
222-22-2222 ...
...
proc sort data = Have;
by SSN Visit_Date;
run;
data Want;
set Have;
by SSN;
if last.SSN;
run;
Do you have a recorded date in your data to sort on as well as SSN? If not how would you identify the last recorded SSN?
Yes, there is a corresponding visit date for each observation. We are being asked to select the observation with the most recent visit date per SSN.
proc sort data = Have;
by SSN Visit_Date;
run;
data Want;
set Have;
by SSN;
if last.SSN;
run;
Can you show us your code so far?
No I'm sorry, this code is for a class so I cannot provide my code verbatim.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: