Hi
I have two more or less identical .csv files.
However, if I insheet both .csv files by using
respectively
the first variable (code) of the first .csv file is formatted as string and the first variable (code) of the sencond .csv file is formatted as numeric.
I checked both csv. files. In Excel they have the same format.
So I have no idea what is the reason for that.
However, I thought maybe it is possible to change the format afterwards.
So what I would like to do is to to change the variable if it is numeric to string. If it is allready a string variable, it is ok.
I use this command
This code works if the variable code is numeric. But if code is a string an error message appears that the variable "code" is allready formatted as string and therefore no new variable "code2" will be generated.
So what I need is something like a condition that tells stata to change the format from numeric to string only if the variable is numeric.
Any ideas?
I have two more or less identical .csv files.
However, if I insheet both .csv files by using
Code:
insheet using "example1.csv",delimiter (";")
Code:
insheet using "example2.csv",delimiter (";")
I checked both csv. files. In Excel they have the same format.
So I have no idea what is the reason for that.
However, I thought maybe it is possible to change the format afterwards.
So what I would like to do is to to change the variable if it is numeric to string. If it is allready a string variable, it is ok.
I use this command
Code:
tostring code, gen(code2) format(%15.0f) drop code ren code2 code
So what I need is something like a condition that tells stata to change the format from numeric to string only if the variable is numeric.
Any ideas?
Comment