title: Reading stata files with large variables in stata and R
body: <p>I am trying to read the <code>stata</code> files of size 320 MB in <code>stata</code> and <code>R</code> with more than 5000 variables. I used first <code>stata</code> to read the file but the maximum variable that it can read is 5000. So, I can't use stata to read the <code>stata</code> file. My questions are: </p>
  
  <ol>
  <li><p>Is there a way to read the <code>stata</code> file using <code>stata</code> by first asking to keep only variables (I know the variables) so that number of variables is less than 5000? </p></li>
  <li><p>Is there way that I can read this <code>stata</code> file in <code>R</code>?. I am using 32 bit (Vista) and <code>R</code> is giving me the error. <code>"Error: cannot allocate vector of size 21k.Kb"</code>.</p></li>
  </ol>
  
  <p>I used the following R code to read the file :</p>
  
  <pre><code>  #The stata file is in the webpage: http://www.federalreserve.gov/econresdata/scf/scf_2010survey.htm#STATADAT
  #1. set mem 400m
  set maxvar 4000
  use p10i6.dta, clear
  keep x8166 x8167 x8168 x8163 x8164 x2422 x2506 x2606 x2623 x604 x614 x623 x716 x507  x513 x526 x1706 x1705 x1806 x1805 x1906 x1905 x2002 x2012 x1409 x1509 x1609 x1415 x1515 x1615 x1417 x1517 x1617 x1619 x1621 x3124 x3224 x3324 x3129 x3229 x3329 x3335 x3408 x3412 x3416 x3420 x3424 x3428 x4020 x4024 x4028 x4018 x4022 x4026 x4030 x4022 x4026 x4030 x4018 x3507 x3511 x3515 x3519 x3523 x3527 x3506 x3510 x3514 x3518 x3522 x3526 x3529 x3804 x3807 x3810 x3813 x3816 x3818 x3930 x3721 x3821 x3823 x3825 x3827 x3829 x3822 x3824 x3826 x3828 x3830 
  save p10i6.dta, clear     
  
  
  #2. 
          library (foreign)
          year&lt;-2010
          yr &lt;- substr( year , 3 , 4 )
          p10i6.dta&lt;-read.dta(paste0( "p" , yr , "i6.dta" ))
          saveRDS(p10i6.dta,file=paste0( "p" , yr , "i6.rda" ))
          p10i6.rda&lt;-readRDS(paste0( "p" , yr , "i6.rda" ))
  </code></pre>