title: Keep only specific variables while importing a SAS Export file into R using SASxport
body: <p>I'm trying to import a SAS Export file into R using the SASxport library.  I can read the whole file, but cannot seem to limit the import to specific variables.  This should be possible using the &quot;keep=&quot; argument in read.xport; however, all the documentation I can find shows the option &quot;keep=NULL&quot; never with the syntax for actually using the argument.</p>
  <p>To demonstrate, download the Demographics file from NHANES <a href="https://wwwn.cdc.gov/Nchs/Nhanes/2013-2014/DEMO_H.XPT" rel="nofollow noreferrer">here</a>, and save it into your working directory.</p>
  <p>Here's the code that works:</p>
  <pre><code>test &lt;- read.xport(&quot;DEMO_H.XPT&quot;)
  </code></pre>
  <p>But what I want to do is keep only four variables, using the equivalent of &quot;(keep =seqn RIAGENDR RIDAGEYR RIDRETH1)&quot; in SAS.  I've tried by using this syntax:</p>
  <pre><code>test &lt;- read.xport(&quot;DEMO_H.XPT&quot;, keep =seqn RIAGENDR RIDAGEYR RIDRETH1)
  </code></pre>
  <p>And this one:</p>
  <pre><code>test &lt;- read.xport(&quot;DEMO_H.XPT&quot;, keep = c(&quot;seqn&quot;, &quot;RIAGENDR&quot;, &quot;RIDAGEYR&quot;, &quot;RIDRETH1&quot;))
  </code></pre>
  <p>as well as a few other variations, and none work.  Can anyone help me with the correct syntax?</p>