<?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: Make two datasets based on specific statements in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717318#M27502</link>
    <description>&lt;P&gt;Quote from your initial post:&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;We only consider whether the normal test place is over or under 400 - the close contact for that same test place shall always follow."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, in your own words, only the "normal" observation is to be considered.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Feb 2021 18:26:35 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-02-06T18:26:35Z</dc:date>
    <item>
      <title>Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717272#M27490</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set looking like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="56.21455468596808%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&lt;STRONG&gt;Test place&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="25%"&gt;&lt;STRONG&gt;Method&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="25%"&gt;&lt;STRONG&gt;Capacity&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place A&lt;/TD&gt;
&lt;TD width="25%"&gt;Normal&lt;/TD&gt;
&lt;TD width="25%"&gt;450&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place A&lt;/TD&gt;
&lt;TD width="25%"&gt;Close contact&lt;/TD&gt;
&lt;TD width="25%"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place B&lt;/TD&gt;
&lt;TD width="25%"&gt;Normal&lt;/TD&gt;
&lt;TD width="25%"&gt;500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place B&lt;/TD&gt;
&lt;TD width="25%"&gt;Close contact&lt;/TD&gt;
&lt;TD width="25%"&gt;900&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place C&lt;/TD&gt;
&lt;TD width="25%"&gt;Normal&lt;/TD&gt;
&lt;TD width="25%"&gt;60&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place C&lt;/TD&gt;
&lt;TD width="25%"&gt;Close contact&lt;/TD&gt;
&lt;TD width="25%"&gt;458&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place D&lt;/TD&gt;
&lt;TD width="25%"&gt;Normal&lt;/TD&gt;
&lt;TD width="25%"&gt;47&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;Test place E&lt;/TD&gt;
&lt;TD width="25%"&gt;close contact&lt;/TD&gt;
&lt;TD width="25%"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to have to datasets based on the value of capacity and method&lt;/P&gt;
&lt;P&gt;If capacity is over or equal to 400 for method Normal, then this testplace should be in a dataset called OVER, ALSO the matching testplace but with method close contact should follow with, even though it has a capacity below 400. (e.g. example test place A and B)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the case of test place C which has a capacity below 400 and its matching test place C close contact has over 400 - these corresponding places should be in the dataset UNDER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We only consider whether the normal test place is over or under 400 - the close contact for that same test place shall always follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case for test place D, where it does not have a close contact place - then it should be in the UNDER dataset, as it is under 400.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a case as test place E, where there is only a close contact, but it is over 400, then it should be in the UNDER dataset, as I dont want a close contact without a normal test place in the over dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me please?&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 09:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717272#M27490</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-02-06T09:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717274#M27492</link>
      <description>&lt;P&gt;That's a nice example for using a hash object:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
  over
  under
;
set have;
if _n_ = 1
then do;
  declare hash h (dataset:"have (where=(method = 'Normal' and capacity ge 400))");
  h.definekey("test_place");
  h.definedone();
end;
if h.check() = 0
then output over;
else output under;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Feb 2021 09:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717274#M27492</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-06T09:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717280#M27494</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;This code only gives me a dataset with all testplaces over 400 and the other dataset with under 400.&lt;/P&gt;
&lt;P&gt;It does not take into consideration the rules I showed before:)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a test places - normal is over 400, but its corresponding close contact is under 400 - it should follow with in the OVER dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if a test place - normal is under 400, but its corresponding close contact is over 400 - they should both be in the under dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each test place - normal is the one that determine where its should go with its corresponding close contact&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 10:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717280#M27494</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-02-06T10:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717318#M27502</link>
      <description>&lt;P&gt;Quote from your initial post:&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;We only consider whether the normal test place is over or under 400 - the close contact for that same test place shall always follow."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, in your own words, only the "normal" observation is to be considered.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 18:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717318#M27502</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-06T18:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717319#M27503</link>
      <description>&lt;P&gt;Yes the Normal testplace is the main thing that we look at to confirm whether it is over or under.&lt;/P&gt;
&lt;P&gt;the normals, close contact should just always follow with the normal testplace, no matter the capacity of the close contact.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is only if the close contact do NOT have a Normal test place then you will look at the capacityhere&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 18:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717319#M27503</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-02-06T18:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717320#M27504</link>
      <description>&lt;P&gt;Post example data in usable and unambiguous form (data step with datalines, DO NOT SKIP THIS), and the exact result expected out of this.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 18:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717320#M27504</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-06T18:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Make two datasets based on specific statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717331#M27505</link>
      <description>&lt;P&gt;Transpose the data so that both capacity values are on the same observation.&lt;/P&gt;
&lt;P&gt;Then it is easier to write your logical conditions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards dlm='|' dsd truncover;
  input place :$30. Method :$30. Capacity ;
cards;
Test place A|Normal|450
Test place A|Close contact|23
Test place B|Normal|500
Test place B|Close contact|900
Test place C|Normal|60
Test place C|Close contact|458
Test place D|Normal|47
Test place E|Close contact|4
;

proc transpose data=have out=wide(drop=_name_);
  by place;
  id method ;
  var capacity;
run;

data want ;
  set wide ;
  if normal &amp;lt; 400 then target='UNDER';
  else target='OVER';
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                  Close_
Obs       place        Normal    contact    target

 1     Test place A      450        23      OVER
 2     Test place B      500       900      OVER
 3     Test place C       60       458      UNDER
 4     Test place D       47         .      UNDER
 5     Test place E        .         4      UNDER
&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Feb 2021 22:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Make-two-datasets-based-on-specific-statements/m-p/717331#M27505</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-06T22:24:43Z</dc:date>
    </item>
  </channel>
</rss>

