0

For whatever reasons, my code that used to work does not work anymore and I get the following error message "Error: near ".": syntax error". The code is below. How should I modify it to make it work again? Thank you very much!

uhc_phys <- sqldf("select 
      a.iso3,a.year,a.whoname,a.Phys
      b.iso3,b.year,b.whoname,b.Phys
      min(abs(a.year - b.year)) min_value
    from uhc_hwf a  
    left join uhc_hwf b on a.year - b.year in (0,1,2,3,4,5) and
      a.iso3 = b.iso3 and
      b.Phys is not null
    group by a.iso3, a.year
    having a.year in ('2012','2017')")[1:8]
0

1 Answer 1

1

You are missing commas between some of your selected fields. Try this:

uhc_phys <- sqldf("select 
      a.iso3,a.year,a.whoname,a.Phys        ,
      b.iso3,b.year,b.whoname,b.Phys        ,
      min(abs(a.year - b.year)) min_value
    from uhc_hwf a  
    left join uhc_hwf b on a.year - b.year in (0,1,2,3,4,5) and
      a.iso3 = b.iso3 and
      b.Phys is not null
    group by a.iso3, a.year
    having a.year in ('2012','2017')")[1:8]

(Commas spaced out a bit to highlight which ones are missing.)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I am blind today!
Please accept it if this addresses your question. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.