<?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: Query Dataset (to Excel?) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173071#M44593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Ballardw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I substitute the "and" with an "or" in "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Proc export data=dataset1 (where=(var2='abc' and var3='456'))&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;And how can I switch the equals to a contains?&amp;nbsp; If the row says "this is a dog" I want to query "contains 'dog'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The excel file is, you're exactly right, to copy/paste, pivot, chart, etc.&amp;nbsp; As much as I would like to learn SAS scripting enough to do all of that in the program, I'm not the one who decides this. Practice practice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2014 23:24:42 GMT</pubDate>
    <dc:creator>Tegan</dc:creator>
    <dc:date>2014-04-08T23:24:42Z</dc:date>
    <item>
      <title>Query Dataset (to Excel?)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173069#M44591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset ("Dataset 1") with multiple variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR3&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xyz&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 456&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ghi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to devise a simple query to select rows which contain specified content and export them into an excel file to be named "Dataset 2".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, "put all rows into an excel file where VAR2 contains 'abc' and VAR3 contains '456'" or "put all rows into an excel file where VAR2 contains 'abc' OR VAR3 contains '456'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A) What is the script for this query on Dataset1? and B) Can it be exported as an Excel file or can it only be a sas7bdat?&amp;nbsp; Can it be HTML where I can drag it to Excel?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 23:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173069#M44591</guid>
      <dc:creator>Tegan</dc:creator>
      <dc:date>2014-04-08T23:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query Dataset (to Excel?)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173070#M44592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's probably several dozen ways to accomplish this depending on what you want in the end.&lt;/P&gt;&lt;P&gt;One way, Proc export if you have PC Files module licensed with dataset options to select the records you want&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc export data=dataset1 (where=(var2='abc' and var3='456'))&lt;/P&gt;&lt;P&gt;dbmx=excel file="c:\your path\data.xls";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have more complex selection criteria other than equals or in a list you may need more programming in a data step or Proc sql to create the desired data or a procedure that allows more complex Where statements than the data set options allow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to control order of variables as they appear in the output you may want to use an ODS destination that excel can read and a procedure such as proc print;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But before moving data to Excel I would ask, "What is going to be done in Excel" as often I can do that in SAS and provide the output instead of exporting data and then going through Excel formulae, cell copying/pasting/ formatting to create a pivot table whose results are charted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 23:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173070#M44592</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-04-08T23:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Query Dataset (to Excel?)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173071#M44593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Ballardw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I substitute the "and" with an "or" in "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Proc export data=dataset1 (where=(var2='abc' and var3='456'))&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;And how can I switch the equals to a contains?&amp;nbsp; If the row says "this is a dog" I want to query "contains 'dog'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The excel file is, you're exactly right, to copy/paste, pivot, chart, etc.&amp;nbsp; As much as I would like to learn SAS scripting enough to do all of that in the program, I'm not the one who decides this. Practice practice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 23:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173071#M44593</guid>
      <dc:creator>Tegan</dc:creator>
      <dc:date>2014-04-08T23:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Query Dataset (to Excel?)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173072#M44594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All of the logical operators And, Or, Not and In are supported in the data set option where clause.&lt;/P&gt;&lt;P&gt;However the data set option where clause does not support searching functions. To subset the data&lt;/P&gt;&lt;P&gt;where you need a string to be within another string you will need to use a data step or proc sql to create the desired output.&lt;/P&gt;&lt;P&gt;There are a number of string searching functions depending on what type of string value you want to search for. FIND is one of the generic but FINDW, INDEX, INDEXW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if find(var2,'abc')&amp;gt;0 and find(var3,'456')&amp;gt;0; /* this is a subsetting if, all records kept must meet this requirement*/;&lt;/P&gt;&lt;P&gt;/* if you have multiple requirements and sticking them all together with a bunch of or statments gets too&lt;/P&gt;&lt;P&gt;long you might try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if find(var2,'abc')&amp;gt;0 and find(var3,'456')&amp;gt;0 then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if find(var2,'pdq')&amp;gt;0 and find(var3,'789')&amp;gt;0 then output;&lt;/P&gt;&lt;P&gt;though this approach has a possibility of creating duplicate records*/&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 17:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-Dataset-to-Excel/m-p/173072#M44594</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-04-10T17:31:02Z</dc:date>
    </item>
  </channel>
</rss>

