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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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