I'm importing space-delimited txt files into stata. This is how the data looks like in a text editor.

When I import the data using the following code:
The variables are mislabeled, due to the lack of a variable name for the 'hour' column.
Is there a way to correct this? I have attempted to adapt a solution using macros based on this https://www.statalist.org/forums/for...he-next-column but have failed to do so. Would it involve reordering the columns to call the other column?
Appreciate any advice. Thanks!
When I import the data using the following code:
Code:
import delimited "file.txt", delimiter(space, collapse) varnames(2) rowrange(5)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str10 date str5(sp10 dn10) str4 sg10 str5(at10 t25) float v7 "01/01/2001" "24:00" "7.8" "183." "9.4" "19.9" -99 "02/01/2001" "24:00" "7.6" "185." "10.7" "19.4" -99 "03/01/2001" "24:00" "7.3" "189." "8.6" "19.5" -99 "04/01/2001" "24:00" "6.2" "169." "12.0" "20.2" -99 end
Appreciate any advice. Thanks!
Comment