Hi all,
I need your help with my issues when importing a data file, in txt, to Stata.
I copied and pasted this data set from a website, and it gave me an unwanted line break for different variables in a same observation.
Original txt file is like this.
I used following code for import, and result is as follows
I would like to have Board A, Board B, Board C, Board D on a same row of each observation 1, 3, 5, 7, 9 and so on.
Data
Thank you for your help.
P.S:
Additionally, if v3 in this case, is for a name, that has space in between, not only "userA" but something like "Alex A B C", how do I import that it as a single variable rather than split it to different variables, that's not what I want.
I need your help with my issues when importing a data file, in txt, to Stata.
I copied and pasted this data set from a website, and it gave me an unwanted line break for different variables in a same observation.
Original txt file is like this.
Code:
64421180 by userA on 2024-08-13 11:20:31 UTC Board A (#21) 64388130 by userA on 2024-08-03 13:40:09 UTC Board B (#22) 64374963 by userA on 2024-07-30 16:03:47 UTC Board C (#23) 64371979 by userA on 2024-07-29 15:25:23 UTC Board D (#24) 64371679 by userA on 2024-07-29 13:45:30 UTC Board E (#25)
Code:
import delimited test.txt, delimiter(" ", collapse) clear
Code:
. list +----------------------------------------------------------+ | v1 v2 v3 v4 v5 v6 v7 | |----------------------------------------------------------| 1. | 64421180 by userA on 2024-08-13 11:20:31 UTC | 2. | Board A (#21) | 3. | 64388130 by userA on 2024-08-03 13:40:09 UTC | 4. | Board B (#22) | 5. | 64374963 by userA on 2024-07-30 16:03:47 UTC | |----------------------------------------------------------| 6. | Board C (#23) | 7. | 64371979 by userA on 2024-07-29 15:25:23 UTC | 8. | Board D (#24) | 9. | 64371679 by userA on 2024-07-29 13:45:30 UTC | 10. | Board E (#25) | +----------------------------------------------------------+
Data
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 v1 str2 v2 str5 v3 str2 v4 str10 v5 str8 v6 str3 v7 "64421180" "by" "userA" "on" "2024-08-13" "11:20:31" "UTC" "Board" "A" "(#21)" "" "" "" "" "64388130" "by" "userA" "on" "2024-08-03" "13:40:09" "UTC" "Board" "B" "(#22)" "" "" "" "" "64374963" "by" "userA" "on" "2024-07-30" "16:03:47" "UTC" "Board" "C" "(#23)" "" "" "" "" "64371979" "by" "userA" "on" "2024-07-29" "15:25:23" "UTC" "Board" "D" "(#24)" "" "" "" "" "64371679" "by" "userA" "on" "2024-07-29" "13:45:30" "UTC" "Board" "E" "(#25)" "" "" "" "" end
P.S:
Additionally, if v3 in this case, is for a name, that has space in between, not only "userA" but something like "Alex A B C", how do I import that it as a single variable rather than split it to different variables, that's not what I want.
Comment