Here I am trying to create a start date (AESTDAT) and end date (AEENDAT) variables from the list below. To try and do this for the start date I tried the following on the sample dataset below:
However I received the error message: type mismatch. Diarydate - float %td and event - byte %9.0g. So I converted both to strings using the following and then tried:
I still received the same error message, even though both variables were now string variables. Any idea what I am missing here? Or am I approaching this the wrong way entirely?
Many thanks,
Jenna
Code:
gen AESTDAT = Diarydate if event=="Start"
Code:
tostring event, generate (event2) tostring Diarydate, generate (Diarydate2) gen AESTDAT= Diarydate2 if event2==1
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str1 STUDY_ID int AERPTDAT double AERPTIME str18 AETERM int Diarydate str5 event byte AESEV "A" 22834 -1893385652000 "Increased appetite" 22638 "Start" 2 "A" 22834 -1893385652000 "Increased appetite" 22640 "End" 2 "A" 22834 -1893385652000 "Headache" 22639 "Start" 2 "A" 22834 -1893385652000 "Headache" 22640 "End" 2 "A" 22834 -1893385652000 "Decreased appetite" 22639 "Start" 2 "A" 22834 -1893385652000 "Decreased appetite" 22641 "End" 2 "A" 22834 -1893385652000 "Abdominal pain" 22639 "Start" 2 "A" 22834 -1893385652000 "Abdominal pain" 22640 "End" 2 "A" 22834 -1893385652000 "Abdominal pain" 22643 "Start" 2 "A" 22834 -1893385652000 "Abdominal pain" 22644 "End" 2 "B" 22834 -1893385652000 "Headache" 22719 "Start" 3 "B" 22834 -1893385652000 "Headache" 22720 "End" 3 "B" 22834 -1893385652000 "Headache" 22721 "Start" 3 "C" 22834 -1893385652000 "High BP" 22600 "Start" 2 "C" 22834 -1893385652000 "High BP" 22605 "End" 2 end format %tddd-Mon-YY AERPTDAT format %tcHH:MM:SS AERPTIME format %tddd-Mon-YY Diarydate
Jenna
Comment