BookmarkSubscribeRSS Feed
fengyuwuzu
Pyrite | Level 9

I have a gaming dataset, with ID, play_time, and deposit_time

I want to get the difference betweet first play_time and first deposit_time each month for each ID, and also how many times each ID played between first play_time and first deposit time each month.

 

 

is there a way to sort both time variables in the same data set to get first.play_time and first.deposit_time? I guess not.

 

one way to work around is to sort by ID and play_time first, and output the first.play_time for each ID, and then do the thing to get the first.deposit_time for each ID, and then use these two variables for calculate the diffence between them in days.

 

is there a simpler way to do it? I often feel there are multiple ways to do the same thing and wonder which is the simplest. Thanks.

 

 

 

 

 

2 REPLIES 2
Reeza
Super User

Post sample data and expected output 🙂

 

I feel like I've said this before....

fengyuwuzu
Pyrite | Level 9

The play_time data set:

ID play_time
1 1/1/14 3:04 PM
1 1/1/14 5:29 AM
1 1/1/14 12:58 AM
1 1/1/14 1:19 AM
1 1/2/14 1:29 AM
1 1/2/14 1:33 AM
1 1/2/14 1:39 AM
1 1/2/14 3:39 AM
1 1/2/14 3:44 AM
1 1/2/14 3:45 AM
1 1/3/14 3:47 AM
1 1/3/14 3:50 AM
1 1/3/14 3:51 AM
1 1/3/14 4:12 AM
1 1/3/14 4:17 AM
1 1/5/14 6:11 AM
1 1/5/14 6:19 AM
1 1/6/14 8:58 PM
1 1/8/14 12:04 AM
1 1/8/14 3:19 PM
1 1/8/14 6:45 PM
1 1/8/14 1:11 AM
1 1/9/14 12:47 AM
1 1/11/14 3:10 PM
1 1/11/14 8:34 AM
 
 
2 1/1/14 4:59 PM
2 1/1/14 9:04 PM
2 1/1/14 2:17 PM
2 1/1/14 5:52 AM
2 1/1/14 12:05 AM
2 1/1/14 5:20 AM
2 1/1/14 11:13 PM
2 1/1/14 1:58 AM
2 1/1/14 12:25 AM
2 1/1/14 2:36 AM

 

The deposit_time data set:

ID deposit_time
1 1/4/14 6:19 AM
1 1/7/14 5:26 AM
1 1/9/14 7:18 AM
1 1/13/14 6:15 AM
1 1/22/14 9:11 AM
1 1/28/14 10:26 AM
2 1/5/14 5:19 AM
2 1/14/14 11:23 AM
2 1/19/14 4:38 AM
3 1/11/14 9:42 AM
3 1/22/14 7:25 AM

 

so, for ID 1, the first play time in Jan 2014 is 1/1/2014 12:58 am, and the first deposit time is 1/4/2014  6:19 AM.

What I want:

1) days between first play time and first deposit time, in this case, 3 days;

2) how many plays between first play time and first deposit time, so here 15 plays (all play before 1/4/2014  6:19 AM).

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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