<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: subset data for 45-70% of the observations in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258084#M7035</link>
    <description>&lt;P&gt;Haha, good one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is very very rough sample (original one is too complicated).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname ECLIB000 "D:\Reverse mort"; &lt;BR /&gt;&amp;nbsp; proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; create table ECLIB000.sample&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(Home num,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; avgclosing num,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;variabley num,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;variablex num,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;variablez num);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;insert into ECLIB000.sample&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(600000,4342,100,1200,1400)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(500000,3980,4000,5000,1000)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(400000,3551,1231,12312,111)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(300000,3184,555,6666,8888)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(200000,2801,1231,3453,23432)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(700000,3980,4000,5000,1000)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(200000,3551,1231,12312,111)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(20000,3184,555,6666,8888)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(100000,2801,1231,3453,23432);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;title 'sample';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;select *&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from ECLIB000.sample;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;proc printto; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort ECLIB000.sample;&lt;BR /&gt;by variablex;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*/here is when i need to say keep only the 40%-80% of the dataset (for all variables)*/;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2016 20:55:09 GMT</pubDate>
    <dc:creator>Tita</dc:creator>
    <dc:date>2016-03-21T20:55:09Z</dc:date>
    <item>
      <title>subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258067#M7030</link>
      <description>&lt;P&gt;Hi wonderful SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cant seem to figure out how to subset my dataset for the middle 45-70%. I have 107 variables and about 2000 rows (observations). I need to sort observations by variable X and select 45%-70% percentile of the dataset (that is only observations 900 to 1400). But i do not want to put observations 900 or 1400 as i may need to play with the percentile thus i need a way to figure out how to constrain dataset by %.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help will be apprecaited.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Tita&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258067#M7030</guid>
      <dc:creator>Tita</dc:creator>
      <dc:date>2016-03-21T20:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258072#M7031</link>
      <description>&lt;P&gt;Use PROC RANK to calcuate the percentiles - group=100 and then you can filter from there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258072#M7031</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-21T20:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258074#M7032</link>
      <description>&lt;P&gt;It looks like I cannot choose customized percent?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need this (very rough)&lt;/P&gt;
&lt;P&gt;Data Data1;&lt;/P&gt;
&lt;P&gt;set Data0;&lt;/P&gt;
&lt;P&gt;sort by Variable X;&lt;/P&gt;
&lt;P&gt;keep observations between 0.45*Data0 and 0.7*Data0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I looked at the proc rank, but couldn't find how it can do this. Is it possible for you to elaborate a bit more?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258074#M7032</guid>
      <dc:creator>Tita</dc:creator>
      <dc:date>2016-03-21T20:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258077#M7033</link>
      <description>&lt;P&gt;Please post sample data, if you'd like sample code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;EDIT: or reference a SASHELP data set that can mimic your data.&lt;/P&gt;
&lt;P&gt;SASHELP.CARS and CLASS are popular.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258077#M7033</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-21T20:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258082#M7034</link>
      <description>&lt;P&gt;I'm not sure why you need to sample what appears to be within&amp;nbsp; a specific range of values of your variable X but another option might be to use Proc Survey select. You can specify a sample rate of any specific percentage: Samprate= 0.45 or Samprate=45 and generate a random sample of the specified rate. Or use SAMPSIZE=n to specify a specific number of records.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258082#M7034</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-03-21T20:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258084#M7035</link>
      <description>&lt;P&gt;Haha, good one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is very very rough sample (original one is too complicated).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname ECLIB000 "D:\Reverse mort"; &lt;BR /&gt;&amp;nbsp; proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; create table ECLIB000.sample&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(Home num,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; avgclosing num,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;variabley num,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;variablex num,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;variablez num);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;insert into ECLIB000.sample&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(600000,4342,100,1200,1400)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(500000,3980,4000,5000,1000)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(400000,3551,1231,12312,111)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(300000,3184,555,6666,8888)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(200000,2801,1231,3453,23432)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(700000,3980,4000,5000,1000)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(200000,3551,1231,12312,111)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(20000,3184,555,6666,8888)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values(100000,2801,1231,3453,23432);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;title 'sample';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;select *&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from ECLIB000.sample;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;proc printto; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort ECLIB000.sample;&lt;BR /&gt;by variablex;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*/here is when i need to say keep only the 40%-80% of the dataset (for all variables)*/;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258084#M7035</guid>
      <dc:creator>Tita</dc:creator>
      <dc:date>2016-03-21T20:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258087#M7036</link>
      <description>&lt;P&gt;You're using percent and percentile interchangeably - they're not. Are you looking for a percent of data or data within a specific percentile based on a single variable?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 20:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258087#M7036</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-21T20:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258090#M7037</link>
      <description>&lt;P&gt;Reeza, you are right. I am looking into percentiles (all sorted by variable x);&lt;/P&gt;
&lt;P&gt;obs 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; (delete)&lt;/P&gt;
&lt;P&gt;obs 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; (delete)&lt;/P&gt;
&lt;P&gt;obs 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; (delete)&lt;/P&gt;
&lt;P&gt;obs 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; (keep)&lt;/P&gt;
&lt;P&gt;obs 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; (keep)&lt;/P&gt;
&lt;P&gt;obs 6 &amp;nbsp; &amp;nbsp; &amp;nbsp; (keep)&lt;/P&gt;
&lt;P&gt;obs 7 &amp;nbsp; &amp;nbsp; &amp;nbsp; (keep)&lt;/P&gt;
&lt;P&gt;obs 8 &amp;nbsp; &amp;nbsp; &amp;nbsp; (delete)&lt;/P&gt;
&lt;P&gt;obs 9 &amp;nbsp; &amp;nbsp; &amp;nbsp; (delete)&lt;/P&gt;
&lt;P&gt;obs10 &amp;nbsp; &amp;nbsp; &amp;nbsp;(delete)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new dataset;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;obs 4&lt;/P&gt;
&lt;P&gt;obs 5&lt;/P&gt;
&lt;P&gt;obs 6&lt;/P&gt;
&lt;P&gt;obs 7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it can't be a random sample. I specifically want 40%-70% percentile (if i used the word correctly).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 21:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258090#M7037</guid>
      <dc:creator>Tita</dc:creator>
      <dc:date>2016-03-21T21:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258091#M7038</link>
      <description>I tried but this only does random sampling. I am not sampling but constraining the dataset.</description>
      <pubDate>Mon, 21 Mar 2016 21:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258091#M7038</guid>
      <dc:creator>Tita</dc:creator>
      <dc:date>2016-03-21T21:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258092#M7039</link>
      <description>&lt;P&gt;Here's a program that may be "close enough".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have nobs=_nobs_;&lt;/P&gt;
&lt;P&gt;if (0.45 * _nobs_ &amp;lt;= _n_ &amp;lt;= 0.70 * _nobs_);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It assumes your data set is sorted, and takes all observations falling in the right range, using the observation count.&amp;nbsp; Some notes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;This is simple logic.&amp;nbsp; So there may be slightly more complex versions that run a little faster.&amp;nbsp; Given the size of&amp;nbsp; your data set, that didn't seem like a priority.&lt;/LI&gt;
&lt;LI&gt;Handling ties can be an issue.&amp;nbsp; This program goes by the observation number.&amp;nbsp; There could be some observations that are included, and some that are excluded, even though they have the same value for your variable.&lt;/LI&gt;
&lt;LI&gt;It should be easy to edit the cutoffs since the code is so short.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this close enough?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 21:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258092#M7039</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-21T21:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258093#M7040</link>
      <description>&lt;P&gt;Use this example - I don't have time to code something at the moment:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473612.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473612.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Except use groups=100. Then you'll have your data into percentile groups and can choose the groups you need. If your data has a lot of ties this won't work well...and you should specify how to handle ties anyways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 21:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258093#M7040</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-21T21:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258097#M7041</link>
      <description>Perfect! Thanks so much. This is exactly what i was looking for. You saved me many days of experimenting.</description>
      <pubDate>Mon, 21 Mar 2016 21:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/258097#M7041</guid>
      <dc:creator>Tita</dc:creator>
      <dc:date>2016-03-21T21:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: subset data for 45-70% of the observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/259466#M7080</link>
      <description>&lt;P&gt;A minor tweak (simple, but improves efficiency), or &amp;nbsp;a major one (more complex but a lot more efficiency in the case of large data sets).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Minor (don't bother reading the last 30% of the file):&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have nobs=_nobs_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; _n_ &amp;gt; 0.45*_nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ &amp;gt; 0.70 * _nobs_ then stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above actually reads (and throws away) the first unwanted 45% of the file, but at least stops once the 70% obs has been reached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Major tweak. But if your file is big, you might want to avoid reading the first 45%, just to throw it away.&amp;nbsp; You can use the data set parameter FIRSTOBS&amp;nbsp;to tell sas to skip the first 45% (and the OBS parameter to tell it to stop at 70%).&amp;nbsp; To do that&amp;nbsp;ask dictionary.tables for the number of observations, and use&amp;nbsp;macro expressions to calculate FIRSTOBS and OBS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; select nobs into :nrecs from dictionary.tables where libname='WORK' and memname='HAVE';&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;%let fobs=%sysfunc(floor(%sysevalf(0.45*&amp;amp;nrecs)));&lt;BR /&gt;%let obs=%sysfunc(ceil(%sysevalf(0.7*&amp;amp;nrecs)));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have (firstobs =&amp;nbsp;&amp;amp;fobs&amp;nbsp;&amp;nbsp; obs=&amp;amp;ob );&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2016 20:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/subset-data-for-45-70-of-the-observations/m-p/259466#M7080</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-03-28T20:41:48Z</dc:date>
    </item>
  </channel>
</rss>

