Dear experienced users of this group,
please help!
Importing an excel file into Stata, I have noted all the observations are being imported as string.
for majority, I can use a simple command to convert from string to numerical, if indicated.
But for dates, how should I format it?
To give you an example,
variables that represent dates are:
dateofconsent
dateoffirstconsultation
which are imported as str10 variables
when I browse the observations - they are displayed in MM/DD/YYYY format.
I guess my question is
How can I edit this variable so that it displays the date as DD/MM/YYYY and also, formatted in such as way that allows me to calculate the difference between two dates.
Hope that makes send.
As always, thank you for your help!
please help!
Importing an excel file into Stata, I have noted all the observations are being imported as string.
for majority, I can use a simple command to convert from string to numerical, if indicated.
But for dates, how should I format it?
To give you an example,
PHP Code:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
trialno str12 %12s trialno
trialsite str3 %9s TrialSite
sex str3 %9s Sex
ethnicgroup str7 %9s EthnicGroup
dateofconsent str10 %10s DateOfConsent
dateoffirstco~n str10 %10s DateOfFirstConsultation
ageatextract str4 %9s AgeAtExtract
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sorted by:
dateofconsent
dateoffirstconsultation
which are imported as str10 variables
when I browse the observations - they are displayed in MM/DD/YYYY format.
I guess my question is
How can I edit this variable so that it displays the date as DD/MM/YYYY and also, formatted in such as way that allows me to calculate the difference between two dates.
Hope that makes send.
As always, thank you for your help!

Comment