I would like to transfer a data record from the long to the wide format and combine entries with identical contents in one column.
More specifically, I work with patent data and I want there to be one row per patent and the patent classes to be in columns so that the same patent classes are in the same columns. The initial data set looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int patent_id str1 ipc_class 100 "1" 100 "3" 100 "2" 101 "3" 101 "2" 101 "1" 101 "1" 102 "5" 102 "7" 102 "6" 103 "2" 103 "1" 103 "3" 103 "3" end
The end result should look like this (duplicates in ipc_class in each patent_id were deleted):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int patent_id str1(ipc_class1 ipc_class2 ipc_class3 ipc_class4 ipc_class5 ipc_class6 ipc_class7) 100 "1" "2" "3" "." "." "." "." 101 "1" "2" "3" "." "." "." "." 102 "." "." "." "." "5" "6" "7" 103 "1" "2" "3" "." "." "." "." end
Unfortunately, the reshape command does not seem to serve the purpose. I am happy about tips and hints!
Best,
Marvin
0 Response to Reshape data and order contents in columns
Post a Comment