Please note I am using Stata 15.0, I can not use Datex as its available from 15.1. I can not download this function as the database is stored remotely, and not connected to the internet.
Question: I have generated a new column, 'PreviouTrauma' to combine all the values in the 3 columns below. But the problem is, I am unable to replace completely the values for '0' and 'Null' for column indfor_failedfixation - the remaining 2 columns are not an issue.
The three columns below are all STRING values
SECTION 1
SECTION 2
The values in bold are the total number of values with I used the code
tab indfor_prevtrauma
tab indfor_trauma
tab indfor_failedfixation
SECTION 3
I would like to generate a column combining all three columns with the following values, with a generic column name as ‘PreviousTrauma’
0 - No
1 - Yes
3- NULL
Code used:
generate PreviousTrauma = .
replace PreviousTrauma =1 if indforprev_trauma == “1” | indfor_trauma == “1” | indfor_failedfixation == “1”
replace PreviousTrauma = 0 if indforprev_trauma == “0” | indfor_trauma == “0”
//I then checked the changes made which are equal to the values in the tab code used (SECTION 2) with results shown in the bold section (Section 1)//
replace PreviousTrauma = 0 if indfor_failedfixation == “0”
//Only 39 changes made which is inaccurate as there are 20245 values with ‘0’
SECTION 4
Another problem is when I start with the NULL section for one of the columns (see -Section 4.C)
//A - all changes made accurately
replace PreviousTrauma = 3 if indforprev_trauma == “NULL”
//B - all changes made accurately
replace PreviousTrauma = 3 if indfor_trauma == “NULL”
//C -
replace PreviousTrauma = 3 if indfor_failedfixation == “NULL”
For C - no real changes made when I know from Section 2 and values in Section 1 that there are 1268092 values with ‘NULL’ in this column
I then checked the changes made which are equal to the values in the tab code used (SECTION 2) with results shown in the bold section (Section 1)
Question:
To my mind, I can not see an issue with the code, but perhaps I stand to be corrected. Or is this an issue with the data?
Question: I have generated a new column, 'PreviouTrauma' to combine all the values in the 3 columns below. But the problem is, I am unable to replace completely the values for '0' and 'Null' for column indfor_failedfixation - the remaining 2 columns are not an issue.
The three columns below are all STRING values
SECTION 1
indfor_prevtrauma | indfor_trauma | indfor_failedfixation |
0 | 0 | 0 |
1 | 1 | 1 |
NULL | NULL | NULL |
0 | 0 | 0 |
1 | 1 | 1 |
0 - 1260089, 1 - 8002, Null - 252 |
0 - 20212, 1 - 39, NULL - 1268092 |
0 - 20245, 1 - 6, Null 1,268,092 |
SECTION 2
The values in bold are the total number of values with I used the code
tab indfor_prevtrauma
tab indfor_trauma
tab indfor_failedfixation
SECTION 3
I would like to generate a column combining all three columns with the following values, with a generic column name as ‘PreviousTrauma’
0 - No
1 - Yes
3- NULL
Code used:
generate PreviousTrauma = .
replace PreviousTrauma =1 if indforprev_trauma == “1” | indfor_trauma == “1” | indfor_failedfixation == “1”
replace PreviousTrauma = 0 if indforprev_trauma == “0” | indfor_trauma == “0”
//I then checked the changes made which are equal to the values in the tab code used (SECTION 2) with results shown in the bold section (Section 1)//
replace PreviousTrauma = 0 if indfor_failedfixation == “0”
//Only 39 changes made which is inaccurate as there are 20245 values with ‘0’
SECTION 4
Another problem is when I start with the NULL section for one of the columns (see -Section 4.C)
//A - all changes made accurately
replace PreviousTrauma = 3 if indforprev_trauma == “NULL”
//B - all changes made accurately
replace PreviousTrauma = 3 if indfor_trauma == “NULL”
//C -
replace PreviousTrauma = 3 if indfor_failedfixation == “NULL”
For C - no real changes made when I know from Section 2 and values in Section 1 that there are 1268092 values with ‘NULL’ in this column
I then checked the changes made which are equal to the values in the tab code used (SECTION 2) with results shown in the bold section (Section 1)
Question:
To my mind, I can not see an issue with the code, but perhaps I stand to be corrected. Or is this an issue with the data?
Comment