<?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: How to code Physical Activity in NHANES in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560535#M156767</link>
    <description>&lt;P&gt;Any calculation that involves a missing value for a variable is likely to result in a missing value for the entire line. You can reduce that to some extent by using the SUM function instead of +.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;x= sum( 1,2,.) =&amp;gt;3&lt;/P&gt;
&lt;P&gt;x= 1+2+.&amp;nbsp; =&amp;gt; missing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So instead of&lt;/P&gt;
&lt;PRE&gt;totPA=(paq610*pad615*8)+(paq625*pad630*4)+(paq640*pad645*4)+(paq655*pad660*8)+(paq670*pad675*4);
&lt;/PRE&gt;
&lt;P&gt;try&lt;/P&gt;
&lt;PRE&gt;totPA=sum ((paq610*pad615*8),(paq625*pad630*4),(paq640*pad645*4),(paq655*pad660*8),(paq670*pad675*4) );
&lt;/PRE&gt;
&lt;P&gt;And similar for all the other additions you have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post LOG entries in a code box opened with the forum's {I} or "running man" icon. It is extremely hard to copy and paste from a picture and make comments of the text.&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2019 14:53:01 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-21T14:53:01Z</dc:date>
    <item>
      <title>How to code Physical Activity in NHANES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560375#M156679</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a total newbie in SAS and I'm writing my thesis using the NHANES data. I couldn't quite figure out how to code the physical activity classification and I would really appreciate it if anyone could help me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of my covariate factors is total physical activity and I have referred to the &lt;A href="https://www.who.int/ncds/surveillance/steps/GPAQ%20Instrument%20and%20Analysis%20Guide%20v2.pdf" target="_self"&gt;GPAQ&lt;/A&gt; (Global Physical Activity Questionnaire) guide from WHO. I matched it with the variables from NHANES codebook and I'm trying to classify it by level of total physical activity.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gpaq.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29666i57E542CB76D44A59/image-size/large?v=v2&amp;amp;px=999" role="button" title="gpaq.PNG" alt="gpaq.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The translated variables are the following:&lt;/P&gt;&lt;P&gt;P2 (# of days vigorous work) = paq610&lt;/P&gt;&lt;P&gt;P3 (# of mins vigorous work/day) = pad615&lt;/P&gt;&lt;P&gt;P5 (# of days moderate work) = paq625&lt;/P&gt;&lt;P&gt;P6 (# of mins moderate work/day) = pad630&lt;/P&gt;&lt;P&gt;P8 (# of days walk or bicycle) = paq640&lt;/P&gt;&lt;P&gt;P9 (# of mins walk/bicycle for transportation) = pad645&lt;/P&gt;&lt;P&gt;P11 (# of days vigorous recreational activities) = paq655&lt;/P&gt;&lt;P&gt;P12 (# of mins vigorous recreational&amp;nbsp;activities) = pad660&lt;/P&gt;&lt;P&gt;P14 (# of days moderate recreational activities) = paq675&lt;/P&gt;&lt;P&gt;P15 (# of mins moderate work/day) = pad675&lt;/P&gt;&lt;P&gt;P16 (# of mins sedentary activity) = pad680&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came up with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Physical Activity*/
data demo_dep9; 
	set demo_dep8; 
	/*compute total physical activity or total MET-min/week*/

	totPA=(paq610*pad615*8)+(paq625*pad630*4)+(paq640*pad645*4)+(paq655*pad660*8)+(paq670*pad675*4);
	if (paq610+paq655)&amp;gt;=3 and totPA&amp;gt;=150 or
		(paq610+paq625+paq640+paq655+paq670)&amp;gt;=7 or totPA&amp;gt;=300
	then PAlevel=1; /*High PA Level*/

	if (paq610+paq655)&amp;gt;=3 and ((paq610*pad615)+(paq655*pad660))&amp;gt;=60 or
		(paq625+paq640+paq670)&amp;gt;=5 and ((paq625*pad630)+(paq640*pad645)+(paq670*pad675))&amp;gt;=150 or
		(paq610+paq625+paq640+paq655+paq670)&amp;gt;=5 and totPA&amp;gt;=60
	then PAlevel=2; /*moderate PA level*/
	else PAlevel=3; /*low PA level*/
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I got the following result and it seems that most of the calculations didn't go through.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PA result.PNG" style="width: 514px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29671iCE27E1D6842108D2/image-size/large?v=v2&amp;amp;px=999" role="button" title="PA result.PNG" alt="PA result.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="log results.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29672i0C0BCE8D2A9A58C9/image-size/large?v=v2&amp;amp;px=999" role="button" title="log results.PNG" alt="log results.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got these log results. I am quite confused as to what happened. I'd really appreciate any help or advice. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 04:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560375#M156679</guid>
      <dc:creator>abigailpuno</dc:creator>
      <dc:date>2019-05-22T04:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to code Physical Activity in NHANES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560535#M156767</link>
      <description>&lt;P&gt;Any calculation that involves a missing value for a variable is likely to result in a missing value for the entire line. You can reduce that to some extent by using the SUM function instead of +.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;x= sum( 1,2,.) =&amp;gt;3&lt;/P&gt;
&lt;P&gt;x= 1+2+.&amp;nbsp; =&amp;gt; missing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So instead of&lt;/P&gt;
&lt;PRE&gt;totPA=(paq610*pad615*8)+(paq625*pad630*4)+(paq640*pad645*4)+(paq655*pad660*8)+(paq670*pad675*4);
&lt;/PRE&gt;
&lt;P&gt;try&lt;/P&gt;
&lt;PRE&gt;totPA=sum ((paq610*pad615*8),(paq625*pad630*4),(paq640*pad645*4),(paq655*pad660*8),(paq670*pad675*4) );
&lt;/PRE&gt;
&lt;P&gt;And similar for all the other additions you have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post LOG entries in a code box opened with the forum's {I} or "running man" icon. It is extremely hard to copy and paste from a picture and make comments of the text.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 14:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560535#M156767</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-21T14:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to code Physical Activity in NHANES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560717#M156868</link>
      <description>&lt;P&gt;Thank you so much! It worked! I just needed to be careful about my parentheses, too. Really appreciate your time and effort answering my question. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS. Will post on the code box for the LOG next time. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks for reminding.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 05:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/560717#M156868</guid>
      <dc:creator>abigailpuno</dc:creator>
      <dc:date>2019-05-22T05:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to code Physical Activity in NHANES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/625355#M184306</link>
      <description>&lt;P&gt;Hello! Was wondering if you were able to help me? I have used the same exact code for my NHANES thesis this year with a different year's data set and have edited totPA=sum (x*x), (x*x).. etc how you have advised, however, am still not getting observations for the high level of PA. The same issue here as above! What else should I revisit in the code? Parenthesis? Change all addition equations to include a "sum" statement?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 17:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-Physical-Activity-in-NHANES/m-p/625355#M184306</guid>
      <dc:creator>indnahc</dc:creator>
      <dc:date>2020-02-17T17:09:25Z</dc:date>
    </item>
  </channel>
</rss>

