<?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: Variable meets 2 criteria in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886914#M43376</link>
    <description>&lt;P&gt;Your requirement appears to be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where somevariablename = "Some value";&lt;/P&gt;
&lt;P&gt;Available in many procedures. Try it with proc freq for simple test.&lt;/P&gt;
&lt;P&gt;Or the dataset option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc something data=yourdatasetname (where=(somevariable='Some Value')) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What the variable name actually is and the actual value in your data is the question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Equality is very strong requirement. If you use ="Corrective" then "Corrective Final" is &lt;STRONG&gt;not&lt;/STRONG&gt; equal and won't match. Neither will "corrective" "CORRECTIVE" "cOrrective" or " Corrective" (see the space at the front). SAS will ignore trailing blanks with equal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2023 21:38:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-07-28T21:38:44Z</dc:date>
    <item>
      <title>Variable meets 2 criteria</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886906#M43374</link>
      <description>&lt;P&gt;I am working with a large data set and trying to figure out how I can create a code where the specimen number meets 2 criteria:&amp;nbsp;Report Status = "CORRECTIVE" and "FINAL" while also keeping all variables in the table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the dataset I have:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Record ID&lt;/TD&gt;&lt;TD&gt;Specimen number&lt;/TD&gt;&lt;TD&gt;Date Collected&lt;/TD&gt;&lt;TD&gt;Report Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;W2345678&lt;/TD&gt;&lt;TD&gt;1/5/2020&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Corrective&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23456&lt;/TD&gt;&lt;TD&gt;M9876799&lt;/TD&gt;&lt;TD&gt;3/4/2023&lt;/TD&gt;&lt;TD&gt;Corrective&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;84569&lt;/TD&gt;&lt;TD&gt;N45678987&lt;/TD&gt;&lt;TD&gt;5/22/2022&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Corrective&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;78766&lt;/TD&gt;&lt;TD&gt;P73839303&lt;/TD&gt;&lt;TD&gt;6/9/2022&lt;/TD&gt;&lt;TD&gt;Final&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;35473&lt;/TD&gt;&lt;TD&gt;R37390202&lt;/TD&gt;&lt;TD&gt;4/7/2023&lt;/TD&gt;&lt;TD&gt;Corrective&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I want:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Record ID&lt;/TD&gt;&lt;TD&gt;Specimen number&lt;/TD&gt;&lt;TD&gt;Date Collected&lt;/TD&gt;&lt;TD&gt;Report Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;W2345678&lt;/TD&gt;&lt;TD&gt;1/5/2020&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Corrective&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;84569&lt;/TD&gt;&lt;TD&gt;N45678987&lt;/TD&gt;&lt;TD&gt;5/22/2022&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Corrective&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also want to create a code where the specimen number has a Report Status as Corrective only but was never Final.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with this? Thank you so much!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 20:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886906#M43374</guid>
      <dc:creator>cort125</dc:creator>
      <dc:date>2023-07-28T20:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Variable meets 2 criteria</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886909#M43375</link>
      <description>&lt;P&gt;I realize you are new here, but we cannot work with data in this form. This is a good example why many people here (including me) insist on data sets provided as SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot tell what the first entry under Report Status is. Is it two words separated by a space? Is it two words separated by a carriage return? Is it something else? (And since Report Status is not a valid variable name, I suspect you are not really showing us a SAS data set anyway, but some type of other view like possibly Excel, which simply is not acceptable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So really really really follow the instructions given and provide us with DATA step code that illustrates your data.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 21:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886909#M43375</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-28T21:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Variable meets 2 criteria</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886914#M43376</link>
      <description>&lt;P&gt;Your requirement appears to be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where somevariablename = "Some value";&lt;/P&gt;
&lt;P&gt;Available in many procedures. Try it with proc freq for simple test.&lt;/P&gt;
&lt;P&gt;Or the dataset option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc something data=yourdatasetname (where=(somevariable='Some Value')) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What the variable name actually is and the actual value in your data is the question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Equality is very strong requirement. If you use ="Corrective" then "Corrective Final" is &lt;STRONG&gt;not&lt;/STRONG&gt; equal and won't match. Neither will "corrective" "CORRECTIVE" "cOrrective" or " Corrective" (see the space at the front). SAS will ignore trailing blanks with equal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 21:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886914#M43376</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-07-28T21:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable meets 2 criteria</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886918#M43377</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446310"&gt;@cort125&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've got already the answer how to filter on row level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"I also want to create a code where the specimen number has a Report Status as Corrective only but was never Final."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Above statement makes me think that you also want a filter on group level. But you don't provide sample Have data and expected result for this question so I'm not going to provide an answer based on guesses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide your sample data via a working SAS datastep that creates such data and post it using the running man icon .&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1690583544296.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86233iF740FDC02EB3D532/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1690583544296.png" alt="Patrick_0-1690583544296.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This allows us to spend the time to create and test code that answers your question instead of spending the time converting some html table to a SAS dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 22:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886918#M43377</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-07-28T22:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variable meets 2 criteria</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886921#M43378</link>
      <description>&lt;P&gt;I suspect that you have not described the data sufficiently as it seem trivial to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First let's convert your listing into an actual dataset.&amp;nbsp; Let's use easier variable names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID $ Specimen :$10. Date :mmddyy. Status &amp;amp;:$20.;
  format date yymmdd10. ;
cards;
12345  W2345678   1/5/2020   Corrective Final
23456  M9876799   3/4/2023   Corrective
84569  N45678987  5/22/2022  Corrective Final
78766  P73839303  6/9/2022   Final
35473  R37390202  4/7/2023   Corrective
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To produce your desired result just test for that value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have;
  where status='Corrective Final';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs     ID      Specimen           Date         Status

 1     12345    W2345678     2020-01-05    Corrective Final
 3     84569    N45678987    2022-05-22    Corrective Final

&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jul 2023 23:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/886921#M43378</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-28T23:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Variable meets 2 criteria</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/888426#M43426</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;input ID $ Specimen :$10. Date :mmddyy. Status &amp;amp;:$20.;&lt;BR /&gt;format date yymmdd10. ;&lt;BR /&gt;cards;&lt;BR /&gt;12345 W2345678 1/5/2020 Corrective Final&lt;BR /&gt;23456 M9876799 3/4/2023 Corrective&lt;BR /&gt;84569 N45678987 5/22/2022 Corrective Final&lt;BR /&gt;78766 P73839303 6/9/2022 Final&lt;BR /&gt;35473 R37390202 4/7/2023 Corrective&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want (drop=cntw);&lt;BR /&gt;set have;&lt;BR /&gt;cntw=countw(Status);&lt;BR /&gt;if cntw &amp;gt;1 then output;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 16:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Variable-meets-2-criteria/m-p/888426#M43426</guid>
      <dc:creator>ajay35</dc:creator>
      <dc:date>2023-08-08T16:58:08Z</dc:date>
    </item>
  </channel>
</rss>

