<?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: how to do a new select by list in a existing dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425453#M104814</link>
    <description>&lt;P&gt;Then wrapping it in a macro and using CALL EXECUTE is your easiest choice.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2018 23:46:16 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-05T23:46:16Z</dc:date>
    <item>
      <title>how to do a new select by list in a existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425448#M104810</link>
      <description>&lt;P&gt;I want to pull out data by SAS from database.&lt;/P&gt;&lt;P&gt;Suppose I have a database with thousands of people's information. I made a filter to randomly select 2 people born from each month of certain year. dataset LIST looks like below:&lt;/P&gt;&lt;P&gt;name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;birthday&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;month&lt;/P&gt;&lt;P&gt;green&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;white&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;brown&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;black&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;and so on&lt;/P&gt;&lt;P&gt;Now I want to use the name as one criterion for another data pulling.&lt;/P&gt;&lt;P&gt;My code will be:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;connect to xxxx(database);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;create table want&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;as select * from connection to database&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(select a.name, a.occupation, a.employer....&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from surveydet.list&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where (a.occupation&amp;nbsp; in xxxxxxxxxx)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and (a.employer in xxxxxxxxxxx)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AND (A.NAME= LIST.NAME);&lt;/P&gt;&lt;P&gt;disconnect from databse;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code seems not work, please help to teach me how to pull data using names exactly pre-selected in dataset LIST.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 23:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425448#M104810</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-01-05T23:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to do a new select by list in a existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425449#M104811</link>
      <description>&lt;P&gt;sorry, in the example, I only list 1 person for each month.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 23:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425449#M104811</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-01-05T23:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to do a new select by list in a existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425451#M104812</link>
      <description>&lt;P&gt;Given what you've shown here, you can't do that because you're using pass through SQL not PROC SQL. This means you're passing the query to the DB so all the data has to be on the data base, including your LIST table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is you can just do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where x in (Select name from list) and occupation in (select .... )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's not quite clear if you want to do it for each name, or for all names at once.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming all names at once you can create a macro variable with the list of names, if it's less than 64K characters in total.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where x in (&amp;amp;name_list)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you'll need to post some more details, your question as it stands is quite vague so it's hard to give specific solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is related to your query from yesterday then CALL EXECUTE is still the best method, IMO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184299"&gt;@leonzheng&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I want to pull out data by SAS from database.&lt;/P&gt;
&lt;P&gt;Suppose I have a database with thousands of people's information. I made a filter to randomly select 2 people born from each month of certain year. dataset LIST looks like below:&lt;/P&gt;
&lt;P&gt;name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;birthday&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;month&lt;/P&gt;
&lt;P&gt;green&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;white&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;brown&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;black&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;Now I want to use the name as one criterion for another data pulling.&lt;/P&gt;
&lt;P&gt;My code will be:&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;connect to xxxx(database);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;create table want&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;as select * from connection to database&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(select a.name, a.occupation, a.employer....&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from surveydet.list&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where (a.occupation&amp;nbsp; in xxxxxxxxxx)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and (a.employer in xxxxxxxxxxx)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AND (A.NAME= LIST.NAME);&lt;/P&gt;
&lt;P&gt;disconnect from databse;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code seems not work, please help to teach me how to pull data using names exactly pre-selected in dataset LIST.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 23:44:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425451#M104812</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-05T23:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to do a new select by list in a existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425453#M104814</link>
      <description>&lt;P&gt;Then wrapping it in a macro and using CALL EXECUTE is your easiest choice.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 23:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425453#M104814</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-05T23:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to do a new select by list in a existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425457#M104815</link>
      <description>&lt;P&gt;Thank you, my real case is much more complicated to describe and contain company information. So I tried to use simple examples to describe my question. I think your suggestion is good. I will try to form a list file and get selection information from it with macro.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 23:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-a-new-select-by-list-in-a-existing-dataset/m-p/425457#M104815</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-01-05T23:57:54Z</dc:date>
    </item>
  </channel>
</rss>

