Hi
I would like to combine multiple categorical variables to one in stata. I went through various posts, tutorials and manuals but could not fond what i want to do, so I am here.
To elaborate, I have observations in the row and variables in the column as below.
I would like stata to recognize 'PRO-SEC' as one variable with content below it. However when I import this data to stata, it generates seperate column for the merged column of 'PRO-SEC' and assigns variable to each columns.
When I encode these string variables as categorical, and apply command, generate sectot= prosec+var10+var11+var12 stata just adds up the numeric value assigned to each categorical variables and sums it up.
How can I have a variable prosec with all the contents in it. (The image i want is shown in the excel)
The question may arise why dont i import it after consolidating it it excel, but the values are too numerous to manually consolidate in excel.
<In excel>
<In stata>
Image of desired outcome
Sorry it seems that the table doesnot appear as table when it is posted.
Many thanks
I would like to combine multiple categorical variables to one in stata. I went through various posts, tutorials and manuals but could not fond what i want to do, so I am here.
To elaborate, I have observations in the row and variables in the column as below.
I would like stata to recognize 'PRO-SEC' as one variable with content below it. However when I import this data to stata, it generates seperate column for the merged column of 'PRO-SEC' and assigns variable to each columns.
When I encode these string variables as categorical, and apply command, generate sectot= prosec+var10+var11+var12 stata just adds up the numeric value assigned to each categorical variables and sums it up.
How can I have a variable prosec with all the contents in it. (The image i want is shown in the excel)
The question may arise why dont i import it after consolidating it it excel, but the values are too numerous to manually consolidate in excel.
<In excel>
No. | PRO-SEC | |||
685 | VAS | |||
687 | VAS | HRQOL | SF-36 | RLS-QOL |
688 | VAS | |||
689 | DLQI | VAS | HAQscore | |
693 | DLQI | HAQscore | SF-36 |
<In stata>
prosec | var10 | var11 | var12 |
VAS | |||
VAS | HRQOL | SF-36 | RLS-QOL |
VAS | |||
DLQI | VAS | HAQscore | |
DLQI | HAQscore | SF-36 |
Image of desired outcome
prosec |
VAS |
VAS |
VAS |
DLQI |
DLQI |
HRQOL |
VAS |
HAQscore |
SF-36 |
HAQscore |
SF-36 |
RLS-QOL |
Many thanks
Comment