Hello!
I have a dataset with 106 observations and 3,165 variables. There are 5 individual surveys included in the dataset (e.g. 5 different time points: baseline, month 2, month 3, month 4, month 5). The variables that appear in all 5 surveys are differentiated by the following variable suffixes: "_1" for baseline, "_2" for month 2, "_3" for month 3, "_4" for month 4, and "_5" for month 5. The stubnames for the variables are relatively complex, and some contain several underscores and/or numbers within the stubname that may impact my ability to reshape the data from its current wide format to long format.
Some examples of the format of the stubnames in my dataset are as follows.
varname
varname1
varname01
varname_100
varname___1
With the month 3 suffix added as an example, the variables look as follows:
varname_3
varname1_3
varname01_3
varname_100_3
varname___1_3
Is it possible to reshape the dataset from wide to long with the above stubnames and suffixes? One of the variables I would like to reshape has the stubname "qol01" and appears in all 5 surveys as qol01_1 qol01_2 qol01_3 qol01_4 qol01_5. I have tried using the string option and the @ option to reshape by survey time point, but keep getting the error message "no xij variables found".
I am sure there is something very simple I am missing here, but would very much appreciate some advice as to whether I will be able to reshape given the current naming format of my variables.
Thanks!
Hannah
I have a dataset with 106 observations and 3,165 variables. There are 5 individual surveys included in the dataset (e.g. 5 different time points: baseline, month 2, month 3, month 4, month 5). The variables that appear in all 5 surveys are differentiated by the following variable suffixes: "_1" for baseline, "_2" for month 2, "_3" for month 3, "_4" for month 4, and "_5" for month 5. The stubnames for the variables are relatively complex, and some contain several underscores and/or numbers within the stubname that may impact my ability to reshape the data from its current wide format to long format.
Some examples of the format of the stubnames in my dataset are as follows.
varname
varname1
varname01
varname_100
varname___1
With the month 3 suffix added as an example, the variables look as follows:
varname_3
varname1_3
varname01_3
varname_100_3
varname___1_3
Is it possible to reshape the dataset from wide to long with the above stubnames and suffixes? One of the variables I would like to reshape has the stubname "qol01" and appears in all 5 surveys as qol01_1 qol01_2 qol01_3 qol01_4 qol01_5. I have tried using the string option and the @ option to reshape by survey time point, but keep getting the error message "no xij variables found".
I am sure there is something very simple I am missing here, but would very much appreciate some advice as to whether I will be able to reshape given the current naming format of my variables.
Thanks!
Hannah
Comment