<?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: if one of these statements is true-PLEASE HELP ME in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488221#M127242</link>
    <description>&lt;P&gt;Its very hard to read code when it is SHOUTED at me.&amp;nbsp; Perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  any_naat=ifc(whichc("P",naatr,naatg,naatp,naatu),"P","N");
run;&lt;/PRE&gt;
&lt;P&gt;Based on your transposed dataset.&amp;nbsp; However you could do the same thing in proc sql without transposing:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as
  select  distinct event_id,
          case when exists(select distinct event_id from test where results="P") then "P" &lt;BR /&gt;               else "N" end as any_naat
  from    test;
quit;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 Aug 2018 14:44:52 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-08-20T14:44:52Z</dc:date>
    <item>
      <title>if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488216#M127240</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I have a data set set similar to this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA TEST;&lt;BR /&gt;INPUT EVENT_ID TEST$ RESULTS $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1234 NAATR N&lt;BR /&gt;1234 NAATG P&lt;BR /&gt;1234 NAATP N&lt;BR /&gt;1234 NAATU N&lt;BR /&gt;1256 NAATU N&lt;BR /&gt;1256 NAATP N&lt;BR /&gt;1256 NAATR N&lt;BR /&gt;1256 NAATG N&lt;BR /&gt;3456 NAATR P&lt;BR /&gt;3456 NAATG P&lt;BR /&gt;3456 NAATP P&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;I sorted and transposed the&amp;nbsp; data set&lt;/P&gt;&lt;P&gt;EVENT_ID NAATR NAATG NAATP NAATU&lt;/P&gt;&lt;P&gt;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; P&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;1256&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;3456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i WOULD LIKE TO HAVE THIS (BELOW)&lt;/P&gt;&lt;P&gt;EVENT_ID ANY_NAAT&lt;/P&gt;&lt;P&gt;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P&lt;/P&gt;&lt;P&gt;1256&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;3456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 14:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488216#M127240</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2018-08-20T14:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488220#M127241</link>
      <description>&lt;P&gt;Can be done directly from the initial dataset with by-processing and retain:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input event_id test $ results $;
datalines;
1234 NAATR N
1234 NAATG P
1234 NAATP N
1234 NAATU N
1256 NAATU N
1256 NAATP N
1256 NAATR N
1256 NAATG N
3456 NAATR P
3456 NAATG P
3456 NAATP P
;
run;

data want (keep=event_id any_naat);
set have;
by event_id;
retain any_naat;
if first.event_id then any_naat = 'N';
if results = 'P' then any_naat = 'P';
if last.event_id then output;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;event_id    any_naat

  1234         P    
  1256         N    
  3456         P    
&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Aug 2018 14:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488220#M127241</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-20T14:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488221#M127242</link>
      <description>&lt;P&gt;Its very hard to read code when it is SHOUTED at me.&amp;nbsp; Perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  any_naat=ifc(whichc("P",naatr,naatg,naatp,naatu),"P","N");
run;&lt;/PRE&gt;
&lt;P&gt;Based on your transposed dataset.&amp;nbsp; However you could do the same thing in proc sql without transposing:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as
  select  distinct event_id,
          case when exists(select distinct event_id from test where results="P") then "P" &lt;BR /&gt;               else "N" end as any_naat
  from    test;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Aug 2018 14:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488221#M127242</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-20T14:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488268#M127251</link>
      <description>Sorry, I was not shouting at you. When I transposed the dataset, I no longer have results variable. It looks like this&lt;BR /&gt;Event_id naatr naatg naatp naatu&lt;BR /&gt;1234 n p n n&lt;BR /&gt;1256 n n n n&lt;BR /&gt;3456 p p p&lt;BR /&gt;&lt;BR /&gt;Since I have no results variable, I could not use results="p"&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&lt;BR /&gt;create table want as&lt;BR /&gt;&lt;BR /&gt;select distinct event_id,&lt;BR /&gt;&lt;BR /&gt;case when exists(select distinct event_id from test where results="P") then "P"&lt;BR /&gt;else "N" end as any_naat&lt;BR /&gt;&lt;BR /&gt;from test;&lt;BR /&gt;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;what should I use instead? Your help will be appreciated.&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Aug 2018 16:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488268#M127251</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2018-08-20T16:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488282#M127254</link>
      <description>&lt;P&gt;The whole transposition business is unnecessary. See my code, and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;'s SQL. Both work from the original dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 17:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488282#M127254</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-20T17:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488447#M127313</link>
      <description>&lt;P&gt;The first code I presented would work on your transposed data, the proc sql works on your original data without need for transposing.&amp;nbsp; Please post test data in the form of a datastep in future:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 07:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488447#M127313</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-21T07:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488480#M127332</link>
      <description>&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by event_id;
if results='N' then ord=0;
else if results='P' then ord=1;
run;


proc sort data=want;
by event_id ord;
run;

data want2;
set want;
by event_id ord;
if last.event_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2018 09:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488480#M127332</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-21T09:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: if one of these statements is true-PLEASE HELP ME</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488549#M127355</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input event_id test $ results $;
datalines;
1234 NAATR N
1234 NAATG P
1234 NAATP N
1234 NAATU N
1256 NAATU N
1256 NAATP N
1256 NAATR N
1256 NAATG N
3456 NAATR P
3456 NAATG P
3456 NAATP P
;
run;
proc sql;
select EVENT_ID ,max(results) as ANY_NAAT
 from have
  group by EVENT_ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2018 13:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-one-of-these-statements-is-true-PLEASE-HELP-ME/m-p/488549#M127355</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-08-21T13:34:57Z</dc:date>
    </item>
  </channel>
</rss>

