BookmarkSubscribeRSS Feed
mar0000
Obsidian | Level 7
data have;
input Person_ID $   date  Date9.     Sport $ ;
format date date9.;
datalines;
1234 20FEB2020 Football 
1234 20FEB2020 Basketball 
1234 25FEB2020 Ski 
1234 07SEP2020 Football

How would I create a variable that says 'Y' for line 1 and 4 because there is at least a 6 month difference between the two days; and 'Y' for line 3 because it is a different type of sport? I want 'N' if it is on the same day and has a different sport, 'Y' if it is on a different day and a different sport, and 'Y' if the same (or different) sport is played with a 6 month difference. 

1 REPLY 1
ballardw
Super User

Anything involving "different type of sport" is going to involve having a list or format that can assign every value of sport of encountered into a "type" category.

So you might start with listing all of your sports and what category you want to use for each.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 536 views
  • 0 likes
  • 2 in conversation