BookmarkSubscribeRSS Feed
peppapig
Calcite | Level 5

Data Have: user_id is for one person, who is taking two types of survey below, the first row in red is showing the final time, and length to finish the 1st survey.

The first row in blue is also showing the final time, and length to finish the 2nd survey. The data could continue to 200 different types of surveys.

user_idsurvey_datesurvey_timeresponse_dateresponse_timelength_second
111/24/201314:00:0011/25/201314:01:0464
111/24/201314:00:0011/25/201314:01:0464
111/24/201314:00:0011/25/201314:01:0464
111/24/201314:00:0011/25/201314:01:0464
111/24/201314:00:0011/25/201314:01:0363
111/24/201314:00:0011/25/201314:01:0060
111/24/201314:00:0011/25/201314:01:0060
111/24/201314:00:0011/25/201314:00:5252
111/24/201314:00:0011/25/201314:00:5252
111/23/201313:00:0011/25/201313:22:001320
111/23/201313:00:0011/25/201313:22:001320
111/23/201313:00:0011/25/201313:22:001320
111/23/201313:00:0011/25/201313:22:001320
111/23/201313:00:0011/25/201313:22:001320
111/23/201313:00:0011/25/201313:21:581318
111/23/201313:00:0011/25/201313:21:581318
111/23/201313:00:0011/25/201313:21:581

?

Want: to create one ID column for survey, like for red block, survey_num = 01, blue block survey_num = 02... then continue...

Once i have the survey_num column, I will sort the data by survey_num, and length, descending,  and keep the first row in each survey, and calculate the mean length, etc....

Thanks for all your help!

1 REPLY 1
Reeza
Super User

What field do you use to identify a survey? The survey_date?

See this link for help as well:

SAS FAQ: How can I create an enumeration variable by groups?

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