<?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: SQL  or any appropriate method to select elements under columns and common exposures in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690642#M9437</link>
    <description>&lt;P&gt;The WHERE must be part of the SELECT, and there can be only&amp;nbsp;&lt;EM&gt;one&lt;/EM&gt; WHERE in a single SELECT.&lt;/P&gt;
&lt;P&gt;For which observations do you want to select in that step? Those where only one agent is true, or those where any agent is true?&lt;/P&gt;</description>
    <pubDate>Sat, 10 Oct 2020 06:31:45 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-10-10T06:31:45Z</dc:date>
    <item>
      <title>SQL  or any appropriate method to select elements under columns and common exposures</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690634#M9436</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Hello, I would appreciate if someone helps me an appropriate approach to complete this task using &lt;BR /&gt;dataset d1 having lung cancer cases cacase and controls popcont exposed to 4 agents a1,a2,a3 and a4.&lt;BR /&gt;I need to&lt;BR /&gt;(1)Place exposures(1's) of each agent under its column heading and&lt;BR /&gt;(2)Find the common zeros for all the 4 agents: ie. ids unexposed (0's) to any of the 4 agents and&lt;BR /&gt;place the corresponding agent. The zeros are the ones commmon to all the agents. There are 6 id's unexposed(0's) &lt;BR /&gt;to the agents. ie. each one has 6 zero's.&lt;BR /&gt;In summary: a1: 9 exposures(1's) and 6 unexposures(0)-total 15 obs; a2:10 exposures(1's) and &lt;BR /&gt;the 6 zero's-total 16 obs; a3: 7  1's and 6 zero's-total 13 obs and a4: 6  1's and 6 zero; total 12 obs.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My SAS SQL code to place the 1's under each agent is inappropriate. The only good one is a1 having only&lt;BR /&gt;1's.  Please I would need help here to place the 1's under their corresponding agent.There was an &lt;BR /&gt;error message-the global statement not supported.......&lt;BR /&gt;&lt;BR /&gt;The SAS code and log are found below' the results are attached.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for your help.&lt;BR /&gt;&lt;BR /&gt;data d1;&lt;BR /&gt;input id$ a1 a2 a3 a4  lung$ 14-21;&lt;BR /&gt;datalines;&lt;BR /&gt;os1  1 0 0 1 ca case  &lt;BR /&gt;os2  1 1 0 0 ca case  &lt;BR /&gt;os3  0 0 0 0 pop cont &lt;BR /&gt;os4  1 0 0 1 pop cont &lt;BR /&gt;os5  0 1 0 0 ca case  &lt;BR /&gt;os6  0 0 0 0 ca case  &lt;BR /&gt;os7  1 0 1 1 pop cont &lt;BR /&gt;os8  0 1 0 0 ca case  &lt;BR /&gt;os9  1 0 1 0 pop cont &lt;BR /&gt;os10 0 0 1 0 ca case  &lt;BR /&gt;os11 0 1 0 0 pop cont &lt;BR /&gt;os12 0 1 0 0 pop cont &lt;BR /&gt;os13 1 1 1 1 pop cont  &lt;BR /&gt;os14 0 0 0 0 pop cont &lt;BR /&gt;os15 1 0 0 1 ca case  &lt;BR /&gt;os16 0 1 1 0 pop cont &lt;BR /&gt;os17 1 1 1 1 pop cont  &lt;BR /&gt;os18 0 0 0 0 ca case  &lt;BR /&gt;os19 0 1 0 0 pop cont  &lt;BR /&gt;os20 0 0 0 0 ca case &lt;BR /&gt;os21 0 0 0 0 ca case &lt;BR /&gt;os22 1 1 1 0 ca case&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class="sasSource"&gt;73 data d1;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;74 input id$ a1 a2 a3 a4 lung$ 14-21;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;75 datalines;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote1_1602299098631" class="sasNote"&gt;NOTE: The data set WORK.D1 has 22 observations and 6 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote2_1602299098631" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;98 ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;99&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;100&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;101 /* Step 1: Placing exposed (1's) under each agent*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;102&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;103 /* Frequencies of the exposed (1's)*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;104 proc freq data=d1;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;105 tables a1* lung a2* lung a3*lung a4*lung;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;106 title 'Table 1: frequencies of exposures';&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;107 run;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote3_1602299098631" class="sasNote"&gt;NOTE: There were 22 observations read from the data set WORK.D1.&lt;/DIV&gt;
&lt;DIV id="sasLogNote4_1602299098631" class="sasNote"&gt;NOTE: PROCEDURE FREQ used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.35 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.34 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;108&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;109 data ones; set d1;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote5_1602299098631" class="sasNote"&gt;NOTE: There were 22 observations read from the data set WORK.D1.&lt;/DIV&gt;
&lt;DIV id="sasLogNote6_1602299098631" class="sasNote"&gt;NOTE: The data set WORK.ONES has 22 observations and 6 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote7_1602299098631" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;110 proc sql;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;111 select&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;112 id, a1, a2, a3,a4,lung from d1 where a1=1;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;113 where a2=1; where a3=1; where a4=1;&lt;/DIV&gt;
&lt;DIV id="sasLogWarning1_1602299098631" class="sasWarning"&gt;WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.&lt;/DIV&gt;
&lt;DIV id="sasLogWarning2_1602299098631" class="sasWarning"&gt;WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.&lt;/DIV&gt;
&lt;DIV id="sasLogWarning3_1602299098631" class="sasWarning"&gt;WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;114&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;115 /*Step 2:(a) Finding ids unexposed to 4 agents*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;116&lt;/DIV&gt;
&lt;DIV id="sasLogNote8_1602299098631" class="sasNote"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.09 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.09 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;117 proc freq data=d1(where=(sum(a1,a2,a3,a4)=0));&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;118 tables lung;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;119 title 'Table 2:Subjects unexposed to any of the 4 agents';&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;120 run;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote9_1602299098631" class="sasNote"&gt;NOTE: There were 6 observations read from the data set WORK.D1.&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;WHERE SUM(a1, a2, a3, a4)=0;&lt;/DIV&gt;
&lt;DIV id="sasLogNote10_1602299098631" class="sasNote"&gt;NOTE: PROCEDURE FREQ used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.18 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.18 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;121&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;122 /*(b) Using SQL approach to confirm results of (a) above*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;123 proc sql;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;124 create table t as&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;125 select&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;126 id, a1, a2, a3,a4,lung,&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;127 sum(a1,a2,a3,a4)=0 as ue1234&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;128 from d1&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;129 ;&lt;/DIV&gt;
&lt;DIV id="sasLogNote11_1602299098631" class="sasNote"&gt;NOTE: Table WORK.T created, with 22 rows and 7 columns.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;130 quit;&lt;/DIV&gt;
&lt;DIV id="sasLogNote12_1602299098631" class="sasNote"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.03 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;131 proc print data=t;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;132 title 'Table 3: The 1's are id's unexposed to agents; zeros here are the exposed';&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;________________&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;49&lt;/DIV&gt;
&lt;DIV id="sasLogWarning4_1602299098631" class="sasWarning"&gt;WARNING: The TITLE statement is ambiguous due to invalid options or unquoted text.&lt;/DIV&gt;
&lt;DIV id="sasLogNote13_1602299098631" class="sasNote"&gt;NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;between a quoted string and the succeeding identifier is recommended.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;133 run;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote14_1602299098631" class="sasNote"&gt;NOTE: There were 22 observations read from the data set WORK.T.&lt;/DIV&gt;
&lt;DIV id="sasLogNote15_1602299098631" class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.19 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.20 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;134&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;135 /* Step 3(Last step) : Placing the Unexposed (0's) under exposed (1's) of each agent*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;136&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;137 /* Not sure what to do here,please*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;138&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;139&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;140&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;141 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;153&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE id="pre_sasLog_548" class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Oct 2020 03:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690634#M9436</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-10-10T03:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: SQL  or any appropriate method to select elements under columns and common exposures</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690642#M9437</link>
      <description>&lt;P&gt;The WHERE must be part of the SELECT, and there can be only&amp;nbsp;&lt;EM&gt;one&lt;/EM&gt; WHERE in a single SELECT.&lt;/P&gt;
&lt;P&gt;For which observations do you want to select in that step? Those where only one agent is true, or those where any agent is true?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 06:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690642#M9437</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-10T06:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: SQL  or any appropriate method to select elements under columns and common exposures</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690678#M9438</link>
      <description>Hi,&lt;BR /&gt;Thanks for responding. Actually, I need to select where any agent is true. I have tried many times, and is not working. Please help.&lt;BR /&gt;ak.</description>
      <pubDate>Sat, 10 Oct 2020 14:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690678#M9438</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-10-10T14:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: SQL  or any appropriate method to select elements under columns and common exposures</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690680#M9439</link>
      <description>&lt;P&gt;You could write this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where a1=1 or a2=1 or a3=1 or a4=1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I prefer this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where sum(a1,a2,a3,a4) &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Oct 2020 15:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SQL-or-any-appropriate-method-to-select-elements-under-columns/m-p/690680#M9439</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-10T15:12:37Z</dc:date>
    </item>
  </channel>
</rss>

