Hi,
I am trying to export a dta file (about 10,000 variables of different formats) as a CSV file so that I can view it as an excel spreadsheet. However, some of my variables are dates with commas (format %dM_d,_CY)
Is there a way to create a foreach loop across all variables of the database, and format them to %tdNN/DD/CCYY only if they either are in %dM_d,_CY format or have values containing commas?
The code below currently produces an error code stating, "varlist must contain all numeric or all string variables," labelled as, "r(109)." Can the code below be corrected, and/or is there an alternative solution?
foreach var of varlist _all {
format %tdDD-NN-CCYY if ustrpos(name, ",")>0 | strpos(name, ",")>0
}
Thank you in advance!
Priscilla
I am trying to export a dta file (about 10,000 variables of different formats) as a CSV file so that I can view it as an excel spreadsheet. However, some of my variables are dates with commas (format %dM_d,_CY)
Is there a way to create a foreach loop across all variables of the database, and format them to %tdNN/DD/CCYY only if they either are in %dM_d,_CY format or have values containing commas?
The code below currently produces an error code stating, "varlist must contain all numeric or all string variables," labelled as, "r(109)." Can the code below be corrected, and/or is there an alternative solution?
foreach var of varlist _all {
format %tdDD-NN-CCYY if ustrpos(name, ",")>0 | strpos(name, ",")>0
}
Thank you in advance!
Priscilla
Comment