How to add Survey_ID column in multiple records data?

Reply
Contributor
Posts: 42

How to add Survey_ID column in multiple records data?

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!

Super User
Posts: 19,770

Re: How to add Survey_ID column in multiple records data?

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?

Ask a Question
Discussion stats
  • 1 reply
  • 125 views
  • 0 likes
  • 2 in conversation