I have two datasets
Dataset_1
PS Lat Long Slot Dist XYZ
abc | 75.8233 | 26.2454 | 1 | 0 | 2 |
abc | 75.4875 | 26.8997 | 2 | 0 | 2 |
xyz | 75.4875 | 26.3842 | 1 | 0 | 2 |
xyz | 75.7861 | 26.6884 | 2 | 0 | 2 |
and
Dataset_2
PS Lat Long Slot Dist XYZ
abc | 75.4785 | 26.4589 | 1 | 0.00 | -100 |
abc | 75.5495 | 26.4679 | 1 | 7929.25 | -100 |
abc | 75.5649 | 26.7268 | 2 | 0.00 | -100 |
abc | 75.5666 | 26.8647 | 2 | 3843.27 | -100 |
xyz | 75.4937 | 26.5877 | 1 | 0.00 | -100 |
xyz | 75.8473 | 26.3971 | 1 | 39820.47 | -100 |
Now I want to append only those data from the second dataset to the first dataset which have dist less than 5000,
so please suggest me a solution
Thnx in advance
If I understand you correctly, the easiest and fastest is probably to use PROC APPEND:
proc append base=dataset_1 data=dataset_2(where=(dist<5000)); run;
You really shouldn't tag users in a question unless you only want that persons answer. They're also under no responsibility to answer your question. In fact, I usually don't when someone does that.
You can use WHERE to filter the results in a SET statement.
data want;
Set first second(where = (dist < 5000));
Run;
And did actually want the 0 distances or only the non-zero distances < 5000?
If I understand you correctly, the easiest and fastest is probably to use PROC APPEND:
proc append base=dataset_1 data=dataset_2(where=(dist<5000)); run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.