I am trying to import a csv file that is structured as below with duplicate variable names:
VariableA,VariableA, VariableA, VariableX,VariableX, VariableX
2.5%, 50%, 97.5%,2.5%, 50%, 975%,
10,20,30,40,30,40
15,25,35,45,30,40
20,30,40,50,30,40
25,35,45,55,30,40
30,40,50,60,30,60
When I import the csv file as
Only the first variable gets the varname, while the duplicates get v2, v3 as
VariableA, v2, v3, VariableX, v5, v6
I have a lot of variables. I need a way to use combined values from the first and second row to create variable names
So, maybe I can start with
without specifying to use row1 as varnames
This creates all variables as v1, v2, v3, v4 and so on
what would be the next step?
Or, is there any other solution?
VariableA,VariableA, VariableA, VariableX,VariableX, VariableX
2.5%, 50%, 97.5%,2.5%, 50%, 975%,
10,20,30,40,30,40
15,25,35,45,30,40
20,30,40,50,30,40
25,35,45,55,30,40
30,40,50,60,30,60
When I import the csv file as
Code:
import delimited using "filename.csv", clear varnames(1)
VariableA, v2, v3, VariableX, v5, v6
I have a lot of variables. I need a way to use combined values from the first and second row to create variable names
So, maybe I can start with
Code:
import delimited using "filename.csv", clear
This creates all variables as v1, v2, v3, v4 and so on
what would be the next step?
Or, is there any other solution?
Comment