BookmarkSubscribeRSS Feed
Shakti_Sourav
Quartz | Level 8
Dear Team,
I want to compare two dataset. I have mentioned below by Example,
Data 1: (Age_1 = Age - 5, Age_2= Age +5 )
NAME. AGE. Age_1. Age_2
ABC 25. 20. 30
Xyz. 20. 15. 25

Data 2:
Name. Age.
ABC. 27
XYZ. 22

Problem:
If data2.Age value is between the data1.age_1 and data1.age_2. then one flag will create. Otherwise flag 0. Like this condition I am unable to do. Please suggest how to do this type of problem ?
1 REPLY 1
PaigeMiller
Diamond | Level 26
proc sql;
    create table want as select
    data2.*
    ,case when data2.age between data1.age_1 and data1.age_2 then 1 else 0 end as flag
    from data1 left join data2
    on upcase(data1.name)=upcase(data2.name);
quit;

 

This code is untested, you need to provide data as working SAS data step code for it to be tested.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 577 views
  • 2 likes
  • 2 in conversation