<?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: SAS code to calculate total duration of exposure to polluting agents in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667973#M9253</link>
    <description>Thank you! Problem resolved. There was an issue with the version.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 09 Jul 2020 07:18:07 GMT</pubDate>
    <dc:creator>ak2011</dc:creator>
    <dc:date>2020-07-09T07:18:07Z</dc:date>
    <item>
      <title>SAS code to calculate total duration of exposure to polluting agents</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/666817#M9239</link>
      <description>&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would appreciate if someone could help me solve this problem with SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From dataset &amp;nbsp;t1 below, for each id_job, &amp;nbsp;I need to calculate the total duration of years of exposure (dur_yrs) for each agent, a1_exp and a2_exp. I have several others, a3_exp, a4_exp……….. I am just using these two as tests.&lt;/P&gt;
&lt;P&gt;The 1’s are exposures and the blanks are un-exposures.&lt;/P&gt;
&lt;P&gt;The dataset, SAS code&amp;nbsp; and log&amp;nbsp; are found below: SAS output are attached.&lt;/P&gt;
&lt;PRE&gt;data t1;&lt;BR /&gt;input id$ 1-6 id_job$ 7-13 dur_yrs 17-19 a1_exp 21-22 a2_exp 24-25;&lt;BR /&gt;datalines;&lt;BR /&gt;osa23 osa23_1   7   1    &lt;BR /&gt;osb17 osb17_1   46  1  1&lt;BR /&gt;osb33 osb33_1   16     1 &lt;BR /&gt;osb33 osb33_2   16     1&lt;BR /&gt;osb44 osb44_1   3   1   &lt;BR /&gt;osb50 osb50_2   4   1  1&lt;BR /&gt;osb50 osb50_2   3   1  1 &lt;BR /&gt;osb67 osb67_2   46  1  1&lt;BR /&gt;osb68 osb68_2   18     &lt;BR /&gt;osb68 osb68_3   18     1&lt;BR /&gt;osb68 osb68_3   30     1 &lt;BR /&gt;osb73 osb73_2   11  1  &lt;BR /&gt;osc16 osc16_2   4   1   &lt;BR /&gt;osc50 osc50_2   14  1  1 &lt;BR /&gt;osc50 osc50_3   14  1  1&lt;BR /&gt;;&lt;BR /&gt; &lt;BR /&gt;proc freq data=t1;&lt;BR /&gt;tables&lt;BR /&gt;a1_exp*dur_yrs&lt;BR /&gt;a2_exp*dur_yrs;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am finding total years of exposure&amp;nbsp;for a1_exp: i.e. 7+46+3+4+3+46+11+4+14+14 =152 years of exposure. I used proc. freq but it could not compute the overall total exposure for me for a1_exp and a2_exp.&lt;/P&gt;
&lt;P&gt;I want to create a new variable for the totals for a1_exp(&lt;STRONG&gt;a1_durtotal&lt;/STRONG&gt;) and a2_exp(&lt;STRONG&gt;a2_durtotal&lt;/STRONG&gt;) and print them out in a table: ie. id&amp;nbsp; id_job……. a1_exp a1_durtotal a2_exp a2_durtotal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your expert help.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 13:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/666817#M9239</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-07-03T13:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to calculate total duration of exposure to polluting agents</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/666918#M9240</link>
      <description>&lt;P&gt;proc&lt;/P&gt;
&lt;PRE&gt;proc sql;
	select sum(dur_yrs) as a1_durtotal 
	from t1
	where a1_exp=1;

	select sum(dur_yrs) as a2_durtotal 
	from t1
	where a2_exp=1;
quit;

data test;
	set t1;
	if a1_exp=1 then a1_durtotal+dur_yrs;
	if a2_exp=1 then a2_durtotal+dur_yrs;
	put a1_durtotal=   a2_durtotal=;
run;&lt;/PRE&gt;
&lt;P&gt;freq&amp;nbsp; has no sum function, you can use&amp;nbsp; data step or proc sql to get total number&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jul 2020 01:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/666918#M9240</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2020-07-04T01:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to calculate total duration of exposure to polluting agents</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667560#M9241</link>
      <description>Hi,&lt;BR /&gt;Thanks very much for your explanation. I really like the sql method but instead of a total duration of 152 yrs for a1_exp, sql gave an output of 250 and instead of 207 yrs for a2_exp, sql gave an output of the same 250 I think there is an error somewhere.. SAS warning was that this SAS  global statement is not supported in SQL.&lt;BR /&gt;Can you please help solve this problem again? Thanks. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 72         &lt;BR /&gt; 73         data t1;&lt;BR /&gt; 74         input id$ 1-6 id_job$ 7-13 dur_yrs 17-19 a1_exp 21-22 a2_exp 24-25;&lt;BR /&gt; 75         datalines;&lt;BR /&gt; &lt;BR /&gt; NOTE: The data set WORK.T1 has 15 observations and 5 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.01 seconds&lt;BR /&gt;       cpu time            0.01 seconds&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 91         ;&lt;BR /&gt; 92         proc print;&lt;BR /&gt; 93         run;&lt;BR /&gt; &lt;BR /&gt; NOTE: There were 15 observations read from the data set WORK.T1.&lt;BR /&gt; NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;       real time           0.18 seconds&lt;BR /&gt;       cpu time            0.19 seconds&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 94         &lt;BR /&gt; 95         proc sql;&lt;BR /&gt; 96         select sum(dur_yrs) as a1_durtotal&lt;BR /&gt; 97         from t1;&lt;BR /&gt; 98         where a1_exp=1;&lt;BR /&gt; WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.&lt;BR /&gt; 99         &lt;BR /&gt; 100        select sum(dur_yrs) as a2_durtotal&lt;BR /&gt; 101        from t1;&lt;BR /&gt; 102        where a2_exp=1;&lt;BR /&gt; WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.&lt;BR /&gt; 103        quit;&lt;BR /&gt; NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;       real time           0.09 seconds&lt;BR /&gt;       cpu time            0.09 seconds&lt;BR /&gt;       &lt;BR /&gt; &lt;BR /&gt; 104        &lt;BR /&gt; 105        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 117 &lt;BR /&gt;</description>
      <pubDate>Tue, 07 Jul 2020 20:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667560#M9241</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-07-07T20:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to calculate total duration of exposure to polluting agents</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667620#M9242</link>
      <description>which sas version you use? &lt;BR /&gt;&lt;BR /&gt;There is no warning, use the PC SAS. Perhaps you can use another method.</description>
      <pubDate>Wed, 08 Jul 2020 02:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667620#M9242</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2020-07-08T02:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to calculate total duration of exposure to polluting agents</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667973#M9253</link>
      <description>Thank you! Problem resolved. There was an issue with the version.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Jul 2020 07:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667973#M9253</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-07-09T07:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to calculate total duration of exposure to polluting agents</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667994#M9254</link>
      <description>Welcome, if your problem is resolved, could you mind to accept my method as your answer.</description>
      <pubDate>Thu, 09 Jul 2020 09:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-calculate-total-duration-of-exposure-to-polluting/m-p/667994#M9254</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2020-07-09T09:29:19Z</dc:date>
    </item>
  </channel>
</rss>

