<?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 New Variable Based on Certain Conditions in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843758#M36623</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;If you do not write anything in case of MET value = .&amp;nbsp; to the output dataset, then you could use:&lt;/P&gt;
&lt;PRE&gt;if &amp;lt;condition&amp;gt; then delete;&lt;/PRE&gt;
&lt;P&gt;to continue with the next line. Hope I understood you correctly.&lt;/P&gt;
&lt;P&gt;--FJa&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2022 12:02:03 GMT</pubDate>
    <dc:creator>fja</dc:creator>
    <dc:date>2022-11-11T12:02:03Z</dc:date>
    <item>
      <title>Create New Variable Based on Certain Conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843713#M36617</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&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.&lt;/P&gt;&lt;P&gt;Hope I made some sense&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;The attached data portion is something I don't want. The highlighted values in the min_week columb need to be missing&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/77192i28E0EE23396DD37A/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:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843713#M36617</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2022-11-11T03:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create New Variable Based on Certain Conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843756#M36622</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data exercise.writeinsMETS;
	set exercise.writeinsMETS;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You should not overwrite the source dataset during development, an i would not do this even after the code has been tested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;if METS="Vigorous" or METS = "Moderate";
else if writein38_min_week=((v5qa38a*v5qa38b*7)/30);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A subsetting-if has no else part, so this will give you a syntax error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make it easier to understand the task, please post data in usable form an show the expected result.&lt;/P&gt;
&lt;P&gt;I don't see the need for that many if-statements, but maybe i don't understand what you are trying to do.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 11:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843756#M36622</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-11-11T11:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create New Variable Based on Certain Conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843758#M36623</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;If you do not write anything in case of MET value = .&amp;nbsp; to the output dataset, then you could use:&lt;/P&gt;
&lt;PRE&gt;if &amp;lt;condition&amp;gt; then delete;&lt;/PRE&gt;
&lt;P&gt;to continue with the next line. Hope I understood you correctly.&lt;/P&gt;
&lt;P&gt;--FJa&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 12:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843758#M36623</guid>
      <dc:creator>fja</dc:creator>
      <dc:date>2022-11-11T12:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create New Variable Based on Certain Conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843761#M36625</link>
      <description>&lt;P&gt;For anyone getting started with the nuances of the IF-THEN-ELSE statements in the SAS DATA step, I recommend this short tutorial by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102238"&gt;@brzcol&lt;/a&gt;:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F80-1P11SbRg%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D80-1P11SbRg&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F80-1P11SbRg%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="200" height="112" scrolling="no" title="SAS Tutorial | If-Then / Else Statements" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 12:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-New-Variable-Based-on-Certain-Conditions/m-p/843761#M36625</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-11-11T12:06:24Z</dc:date>
    </item>
  </channel>
</rss>

