Hello,
I have data in this form
here is the dataex
and I want to convert string and string2 to be:
But when I sort by id and string and try to apply to value to all id, the string is sorted with missing values first
but as I said the blanks are sorted first and this applies the blank to all each id. Is there a way to reverse the sort order? gsort does not seem to work for strings
any help would be great
I have data in this form
id | string | string2 |
1 | ||
1 | N | |
1 | N | |
2 | ||
2 | ||
2 | ||
3 | ||
3 | ||
3 | N | |
3 | ||
3 |
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str1 id str1 string str1 string2 "1" "" "" "1" "N" "" "1" "" "N" "2" "" "" "2" "" "" "2" "" "" "3" "" "" "3" "N" "" "3" "" "" end
and I want to convert string and string2 to be:
id | string | string2 |
1 | N | N |
1 | N | N |
1 | N | N |
2 | ||
2 | ||
2 | ||
3 | N | |
3 | N | |
3 | N | |
3 | N | |
3 | N |
But when I sort by id and string and try to apply to value to all id, the string is sorted with missing values first
Code:
bysort id (string): replace string=string[1]
any help would be great
Comment