<?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: Selecting multiple row data by id simultaneously in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354929#M273992</link>
    <description>&lt;P&gt;Do you have the "projects" of interest in a data set?&lt;/P&gt;
&lt;P&gt;Or are you requesting to analyze the data to find the "top 1000" projects? If this is what you are attempting you will have to define what "top" means and what variables in your data are needed to determine the status.&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2017 14:12:18 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-05-01T14:12:18Z</dc:date>
    <item>
      <title>Selecting multiple row data by id simultaneously</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354924#M273990</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;&lt;BR /&gt;I have about a million rows of data which I want to do some analysis on. The data contains a list of all employees. Each project the employees have worked on has had an opp_IDs attached to it. Each opp_ID may have multiple rows showing what has happened to try to get the project completed and the progress&amp;nbsp;completed. The data thus has 3 levels of nesting.&lt;BR /&gt;&lt;BR /&gt;I am trying to pull just the top 1000 projects by opp_Id and all of their subsequent sub data. Thus there should be many more rows than just the initial 1000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the gist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Employee Name | &amp;nbsp;Opp_ID &amp;nbsp;| &amp;nbsp; MONTH &amp;nbsp;| &amp;nbsp;Progress&lt;/P&gt;&lt;P&gt;John &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp;1234567 &amp;nbsp; | &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp;20&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp;1234567 &amp;nbsp; | &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp;40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;1234567&lt;/STRONG&gt; &amp;nbsp; | &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;| &amp;nbsp;&amp;nbsp;60&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; 324783 &amp;nbsp; | &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; | &amp;nbsp; 80&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; 324783 &amp;nbsp; | &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; | &amp;nbsp; 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sol &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;1234567&lt;/STRONG&gt; &amp;nbsp; | &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp;100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sol &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp;489932&amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp;20&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My desired sorting is simply&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc sort data=have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by Opp_ID month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I only want the top 1000 opp_IDs with all of the subsequent&amp;nbsp;information (Ie. month 1, 2, 3, 4)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Anyone have an idea?&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 15:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354924#M273990</guid>
      <dc:creator>Wolves</dc:creator>
      <dc:date>2017-05-04T15:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting multiple row data by id simultaneously</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354926#M273991</link>
      <description>&lt;P&gt;Can you provide some sample of your data and what you want the outcome to look like?&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 14:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354926#M273991</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-01T14:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting multiple row data by id simultaneously</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354929#M273992</link>
      <description>&lt;P&gt;Do you have the "projects" of interest in a data set?&lt;/P&gt;
&lt;P&gt;Or are you requesting to analyze the data to find the "top 1000" projects? If this is what you are attempting you will have to define what "top" means and what variables in your data are needed to determine the status.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 14:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354929#M273992</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-01T14:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting multiple row data by id simultaneously</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354951#M273994</link>
      <description>&lt;P&gt;Theoretically speaking, it may be best to create a table of the top 1000 opportunity IDs first, and then select all records from your original table that have those ids. &amp;nbsp;As such:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input emp_name $ opp_id month subj_prob;
datalines;
John 1234567 1 20
John 1234567 2 40
John 1234567 3 60
John 324783 1 80
John 324783 2 100
Sol 1234567 4 100
Sol 489932 1 20
;
run;

PROC SQL;
CREATE TABLE TOP1K AS
SELECT OPP_ID, COUNT(*) AS TOTAL FROM HAVE GROUP BY OPP_ID;
QUIT;

PROC SQL OUTOBS=1000;
CREATE TABLE TOP1K AS
SELECT * FROM TOP1K;
QUIT;

PROC SQL;
CREATE TABLE ALLIN1K AS
SELECT * FROM HAVE
INNER JOIN TOP1K ON TOP1K.OPP_ID = HAVE.OPP_ID;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 May 2017 14:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-multiple-row-data-by-id-simultaneously/m-p/354951#M273994</guid>
      <dc:creator>thomp7050</dc:creator>
      <dc:date>2017-05-01T14:46:24Z</dc:date>
    </item>
  </channel>
</rss>

