I'm attempting to import data in a CSV file, where almost all variable values are surrounded by single quotes (apostrophes), as well as being comma delimited. I'd like to remove the single quotes so that I can destring and work with the values. Insheet and import delimited work fine as far as the commas go. I could clearly run through the vars with a loop and something like substr to remove the offending quotes, restricting to leading and trailing characters, and then destring the appropriate variables. But is there a simpler way to do it, perhaps an option for import delimited that I'm not realizing?
Here are the top few lines of the data:
CONTROL,JJOBCOMP,JJOBCOMPYR,JJOBCOST,JJOBDIY,JJOBF UNDS,JJOBTYPE,JJOBWORKYR,JOBTYPE,JOBDIY,JOBCOST,JO BCOMP,JOBCOMPYR,JOBWORKYR,JOBFUNDS
'11000001','0','0','0','0','0','0','0','30','1',30 ,'1','2','-6','1'
'11000002','0','0','0','0','0','0','0','16','2',11 000,'1','1','-6','1'
(It's the 2017 American Housing Survey National Public Use File, available here: https://www.census.gov/programs-surv...ile--puf-.html)
Related Posts with Importing CSV file with surrounding single quotes
Subhazard estimates from stcrreg with multiple (>2) competing hazards.Hi All, I am trying to estimate a competing hazard model ala Fine & Grey (1999). I have three …
Robust Quantile Regression (with robust standard errors)Dear Statalists I run two robustness regression models (rreg & mmregress) with similar (good) r…
foreach loop and localDear all‘ The code below is too long for me.I know it could be replaced by a foreach loop,but I don'…
How to move State ApplicationI have Stata 13 MP on my current laptop (Macbook Air)). I have just bought a new laptop (MacBook Air…
Removing duplicate permutationsHi, I am trying to remove "duplicate permutations". For instance: ID source target 1 A B 2 A C 3 B…
Subscribe to:
Post Comments (Atom)
0 Response to Importing CSV file with surrounding single quotes
Post a Comment