<?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: Proc Print a Subset of Data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102905#M28807</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Oct 2013 12:41:32 GMT</pubDate>
    <dc:creator>mwilso8</dc:creator>
    <dc:date>2013-10-04T12:41:32Z</dc:date>
    <item>
      <title>Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102896#M28798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all, I was hoping someone could help me with a formula that uses Proc Print on one data set for only certain values which are populated in a separate data set. For example if I have the following two tables:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" style="border: 1px solid rgb(0, 0, 0); width: 388px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Unique_Identifier&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE border="1" class="jiveBorder" height="126" style="border: 1px solid rgb(0, 0, 0); width: 852px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Unique_Identifier&lt;BR /&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;175&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Bill&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;165&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;John&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;150&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Mark&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Barkevious&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I write a procedure so that I print of only the values that populate in table 1 under unique identifier?&lt;/P&gt;&lt;P&gt;I have tried just using&lt;/P&gt;&lt;P&gt;proc print data=Table.1; Where Unique_Identifier EQ "1"; run;&lt;/P&gt;&lt;P&gt;proc print data=Table.1; Where Unique_Identifier EQ "1"; run;&lt;/P&gt;&lt;P&gt;proc print data=Table.1; Where Unique_Identifier EQ "1"; run;&lt;/P&gt;&lt;P&gt;And while this works when running a smaller set of data if you try and do this for thousands of variables (which I am hoping to do) it takes to long. Any help I could get would be greatly appreciated, thank you in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 16:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102896#M28798</guid>
      <dc:creator>mwilso8</dc:creator>
      <dc:date>2013-10-03T16:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102897#M28799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you are attempting is not clear. Why would you run the exact same code 3 times? Are wanting to create an output table for each value of unique_identifier? That would be BY group processing which would require sorting if not already done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data= datasetname;&lt;/P&gt;&lt;P&gt;by Unique_identifer;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this isn't what your looking for provide some examples of desired output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 16:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102897#M28799</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-10-03T16:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102898#M28800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As ballardw said your query is not clear but what I learned from the query is that you want to compare the values of Unique Identifier in the two tables and print out the selected obs.&lt;/P&gt;&lt;P&gt;For that you can use Proc SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex: proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from table2 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where select uniqueidentifier in (select uniqueidentifier from table1 where ........);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 16:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102898#M28800</guid>
      <dc:creator>hsharmas</dc:creator>
      <dc:date>2013-10-03T16:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102899#M28801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the quick reply sorry for not being more clear, I made an error in the example code, it was supposed to look like this:&lt;/P&gt;&lt;P&gt;proc print data=Table.1; Where Unique_Identifier EQ "1"; run;&lt;/P&gt;&lt;P&gt;proc print data=Table.1; Where Unique_Identifier EQ "2"; run;&lt;/P&gt;&lt;P&gt;proc print data=Table.1; Where Unique_Identifier EQ "3"; run;&lt;/P&gt;&lt;P&gt;The idea is that the second table contains many unique identifiers and I only want to print a subset of the data. My goal would be for the output table to simply print the contents of the rows in the second table with the Unique_Identifier value of 1,2 and 3. I am hoping to do this on a large data set where I know the values of ~35k unique identifiers and need to extract them from a second table that contains ~5million rows of unique identifiers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that clarifies things&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 16:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102899#M28801</guid>
      <dc:creator>mwilso8</dc:creator>
      <dc:date>2013-10-03T16:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102900#M28802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro print_out();&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select distinct count(uniqueidentifier)&lt;/P&gt;&lt;P&gt;from table1&lt;/P&gt;&lt;P&gt;into: distinct_vars;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data = table1 nodupkey out = uniq;&lt;/P&gt;&lt;P&gt;by uniqueidentifier;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set uniq;&lt;/P&gt;&lt;P&gt;call symput('varb'||LEFT(PUT(_N_, 4.)), TRIM(uniqueidentifier));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to distinct_vars;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods html file&amp;nbsp; = "Print_&amp;amp;distinct_vars..xls";&lt;/P&gt;&lt;P&gt;proc print data = table2;&lt;/P&gt;&lt;P&gt;where uniqueidentifier = "&amp;amp;&amp;amp;varb&amp;amp;i";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods html close;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend print_out;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 17:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102900#M28802</guid>
      <dc:creator>hsharmas</dc:creator>
      <dc:date>2013-10-03T17:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102901#M28803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this should solve the issue....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 17:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102901#M28803</guid>
      <dc:creator>hsharmas</dc:creator>
      <dc:date>2013-10-03T17:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102902#M28804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not nearly advanced as you guys and just need to extract the data so here is what I ended up doing, let me know if you have any thoughts on this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ODS CSV File="C:\Temp.csv";&lt;/P&gt;&lt;P&gt;Proc Print data=Table2;&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;Unique_Identifier EQ 1 or&lt;/P&gt;&lt;P&gt;Unique_Identifier EQ 2 or&lt;/P&gt;&lt;P&gt;Unique Identifier EQ 3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;ODS CSV CLOSE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This worked perfectly for a smaller set of data but I ask for replies because like I said I need to run this on a much larger dataset and am worried about speed/performance. Any help would be much appreciated, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 21:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102902#M28804</guid>
      <dc:creator>mwilso8</dc:creator>
      <dc:date>2013-10-03T21:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102903#M28805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shortcut in syntax for a list of variables is to use the IN operator&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where Unique_identifier in (1,2,3);&lt;/P&gt;&lt;P&gt;Put the values in quotes if they are character values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 21:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102903#M28805</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-10-03T21:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102904#M28806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, as ballardw said you can use an IN operator for selecting set of values. But you mentioned that to print the observations where uniqueidentiier in first table(lookup) are 35k and sec table is 5million. In that case an efficient method is to use PROC SQL. One method is explained above in my first reply and more efficient will be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you have in table1 your set of uniq values which you want to print from table2 which contains a larger set of values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ODS CSV File="C:\Temp.csv";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select a.*&lt;/P&gt;&lt;P&gt;from table2 as a, table1 as b&lt;/P&gt;&lt;P&gt;where a.uniqident = b.uniqident;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ODS CSV File="C:\Temp.csv";&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Oct 2013 22:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102904#M28806</guid>
      <dc:creator>hsharmas</dc:creator>
      <dc:date>2013-10-03T22:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print a Subset of Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102905#M28807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 12:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Print-a-Subset-of-Data/m-p/102905#M28807</guid>
      <dc:creator>mwilso8</dc:creator>
      <dc:date>2013-10-04T12:41:32Z</dc:date>
    </item>
  </channel>
</rss>

