title: I am trying to convert SAS code to R, but I am continuously getting an error "Error: unexpected '}' in " }"
body: <p>This is the sas code to be converted</p>
  
  <pre><code>data dataset; 
  
  if anl01="Y" or anl02="Y" then anl="Y";
  
  if ser="" then do;
  
    if con="Y" or disab="Y" or dth="Y" or hosp="Y" or life="Y" or mie="Y" then ser="Y";
  
   else ser="N";
  
  end;
  
  run;
  </code></pre>
  
  <p>I have written R code like this using if condition, not sure if this works but before that I am getting an error regarding flower brackets</p>
  
  <pre><code>dataframe&lt;-(if ( is.na(dataframe$SER) &amp;&amp; cong=="Y" | disab=="Y" | 
  
  dth=="Y" | hosp=="Y" | 
  
  life=="Y" | mie=="Y"){
  
    dataframe$ser="Y"
  
    } else {
  
      dataframe$ser="N"
  
    })
  </code></pre>