When I need to load a dataset where some specific columns must be read as string I type:
import delimited "data.csv", stringcols(13 15 16)
Where 13, 15 and 16 are the number of columns in my dataset that I want to read as string. However, I usually don't know the columns' numbers beforehand and it would be nice to be able to do the same thing using the columns' names.
I tried:
import delimited "data.csv", stringcols(var1 var2 var3)
But stringcols doesn't accept non-numeric arguments. Is there a way to specify columns types using the columns' names rather than numbers?
In python I can do this using:
df=pd.read_csv("data.csv", dtype={k:str for k in ["var1", 'var2', 'var3']})
I'm looking for a similar method in Stata.