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;
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!
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.
Ready to level-up your skills? Choose your own adventure.