<?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: Creating &amp;quot;IF - AND - THEN&amp;quot; variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758662#M30209</link>
    <description>&lt;P&gt;The DATA and SET statements do not use equal signs.&lt;/P&gt;
&lt;P&gt;By adding them you have created what looks like assignment statements instead to create variables named DATA and SET.&lt;/P&gt;</description>
    <pubDate>Sun, 01 Aug 2021 16:40:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-08-01T16:40:05Z</dc:date>
    <item>
      <title>Creating "IF - AND - THEN" variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758661#M30208</link>
      <description>&lt;P&gt;Hello SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new version of an existing variable that only includes the scores of that existing variable if they correspond to a specific score on another variable. I'm not sure if that makes sense - I've only been using SAS for a month or two. The "str_e2_sq" variable is the severity rating (1 - 4) of a particular stressful life event and the "foc_e2" variable is the rating (1 - 4) of the focus of that event (self, joint, other, pet/possession). So, I'm trying to create variable of severity ratings by the focus of the stressful life event.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This the code I thought would work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data = DHEASLES.sles_master;&lt;BR /&gt;set = DHEASLES.sles_master;&lt;BR /&gt;IF foc_e2 = 1 AND str_e2_sq GE . then str_e2_sq_new = str_e2_sq;&lt;BR /&gt;ELSE str_e2_sq_new = .;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;68&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;69&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;70 Data = DHEASLES.sles_master;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;____&lt;/DIV&gt;&lt;DIV class="sasError"&gt;180&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;71 set = DHEASLES.sles_master;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___&lt;/DIV&gt;&lt;DIV class="sasError"&gt;180&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72 IF foc_e2 = 1 AND str_e2_sq GE . then str_e2_sq_new = str_e2_sq;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;__&lt;/DIV&gt;&lt;DIV class="sasError"&gt;180&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73 ELSE str_e2_sq_new = .;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;____&lt;/DIV&gt;&lt;DIV class="sasError"&gt;180&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 run;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;86&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Thank you so much for the help!&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Best,&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Joe&lt;/DIV&gt;</description>
      <pubDate>Sun, 01 Aug 2021 16:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758661#M30208</guid>
      <dc:creator>jmguzman</dc:creator>
      <dc:date>2021-08-01T16:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating "IF - AND - THEN" variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758662#M30209</link>
      <description>&lt;P&gt;The DATA and SET statements do not use equal signs.&lt;/P&gt;
&lt;P&gt;By adding them you have created what looks like assignment statements instead to create variables named DATA and SET.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Aug 2021 16:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758662#M30209</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-01T16:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating "IF - AND - THEN" variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758676#M30210</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Man, I'm not even sure why I put those equal signs there when I've never done that before. I guess that's what happens when you think that running code on a weekend night instead of relaxing is a good idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Sun, 01 Aug 2021 21:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-quot-IF-AND-THEN-quot-variable/m-p/758676#M30210</guid>
      <dc:creator>jmguzman</dc:creator>
      <dc:date>2021-08-01T21:41:50Z</dc:date>
    </item>
  </channel>
</rss>

