<?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: Create Variables Based on Previous Variable in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843742#M41813</link>
    <description>&lt;P&gt;Here is your IF statement in your own words:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If they do have a MET value, I would like to calculate their average weekly activity (min_week = ((a*b*7)/30)). So, if someone with a MET value =., I don't want to give them an average weekly activity.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you have in your code bears little resemblance to the above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To put this into something close to SAS code, this is what you want, where I leave blanks for you to fill in as a homework assignment,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(_________) then min_week=_____________; else min_week=________;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Explanation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(________) /* you said if they do have a MET value */
then min_week=_________;  /* you said calculate their average weekly activity */
else min_week=__________; /* you said you don't want them to have an average weekly activity */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, it isn't really helpful to have variables in your code that are not mentioned in your explanation, we don't know what they and we don't know how to use them properly.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2022 11:34:38 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-11-11T11:34:38Z</dc:date>
    <item>
      <title>Create Variables Based on Previous Variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843717#M41811</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi everyone!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm creating a new variable, and I'm having issues with the IF-THEN-ELSE statements. For my variable, I would like to calculate the weekly minutes only if that participant has a MET value (either Moderate or Vigorous). Therefore, people without a MET value won't get the calculation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, participants may or may not have a MET value (indicated by Vigorous or Moderate). If they do have a MET value, I would like to calculate their average weekly activity (min_week = ((a*b*7)/30)). So, if someone with a MET value =., I don't want to give them an average weekly activity. The attached data is what I don't want. I don't want the highlighted portions because the participants don't have a METS value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope I made some sense&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data exercise.writeinsMETS;
	set exercise.writeinsMETS;
	if METS="Vigorous" or METS = "Moderate";
	else if writein38_min_week=((v5qa38a*v5qa38b*7)/30);
	else if writein39_min_week=((v5qa39a*v5qa39b*7)/30);
	else if writein40_min_week=((v5qa40a*v5qa40b*7)/30);
	else max(writein38_min_week, writein39_min_week,writein40_min_week) = .;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas.jpg" style="width: 308px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77193iA67AB3CC7F6E61EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas.jpg" alt="sas.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 03:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843717#M41811</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2022-11-11T03:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables Based on Previous Variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843742#M41813</link>
      <description>&lt;P&gt;Here is your IF statement in your own words:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If they do have a MET value, I would like to calculate their average weekly activity (min_week = ((a*b*7)/30)). So, if someone with a MET value =., I don't want to give them an average weekly activity.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you have in your code bears little resemblance to the above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To put this into something close to SAS code, this is what you want, where I leave blanks for you to fill in as a homework assignment,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(_________) then min_week=_____________; else min_week=________;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Explanation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(________) /* you said if they do have a MET value */
then min_week=_________;  /* you said calculate their average weekly activity */
else min_week=__________; /* you said you don't want them to have an average weekly activity */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, it isn't really helpful to have variables in your code that are not mentioned in your explanation, we don't know what they and we don't know how to use them properly.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 11:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843742#M41813</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-11T11:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables Based on Previous Variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843808#M41816</link>
      <description>&lt;P&gt;Thank you so much! I didn't realize my code and variables were not correctly presenteded!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 15:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Create-Variables-Based-on-Previous-Variable/m-p/843808#M41816</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2022-11-11T15:08:03Z</dc:date>
    </item>
  </channel>
</rss>

