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.

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

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