<?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 Why isn't my if then statement working? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394381#M66371</link>
    <description>&lt;P&gt;I'm just getting started and it's very simple code in SAS University. What am I doing wrong?? &amp;nbsp;I get the following message when I run my if-then statement:&lt;SPAN&gt; ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*libnames point to the folder that contains the datasets, not the individual datasets;
libname malawi '/folders/myfolders/'; 
*malawi is the name of the folders and mwfemale_pubuse is the name of the dataset;
proc contents data=malawi.mwfemale_pubuse;

*Age groups 13-17 and 18-24;
if 13 &amp;lt;= q2 &amp;lt;= 18 then agegroup= 1;
if 18 &amp;lt;= q2 &amp;lt;=24 then agegroup= 2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Sep 2017 00:38:24 GMT</pubDate>
    <dc:creator>aliyahh</dc:creator>
    <dc:date>2017-09-09T00:38:24Z</dc:date>
    <item>
      <title>Why isn't my if then statement working?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394381#M66371</link>
      <description>&lt;P&gt;I'm just getting started and it's very simple code in SAS University. What am I doing wrong?? &amp;nbsp;I get the following message when I run my if-then statement:&lt;SPAN&gt; ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*libnames point to the folder that contains the datasets, not the individual datasets;
libname malawi '/folders/myfolders/'; 
*malawi is the name of the folders and mwfemale_pubuse is the name of the dataset;
proc contents data=malawi.mwfemale_pubuse;

*Age groups 13-17 and 18-24;
if 13 &amp;lt;= q2 &amp;lt;= 18 then agegroup= 1;
if 18 &amp;lt;= q2 &amp;lt;=24 then agegroup= 2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 00:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394381#M66371</guid>
      <dc:creator>aliyahh</dc:creator>
      <dc:date>2017-09-09T00:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my if then statement working?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394383#M66372</link>
      <description>&lt;P&gt;Try this:&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;data want;
  set malawi.mwfemale_pubuse;
if 13 &amp;lt;= q2 &amp;lt;= 18 then agegroup= 1;
if 18 &amp;lt;= q2 &amp;lt;=24 then agegroup= 2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 01:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394383#M66372</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-09-09T01:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my if then statement working?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394391#M66374</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163650"&gt;@aliyahh&lt;/a&gt;&amp;nbsp;IF statement can not be used in CONTENTS procedure.&amp;nbsp;&lt;SPAN&gt;The CONTENTS procedure shows the contents of a SAS data set and prints the directory of the SAS library. If you want to do conditional derivation for agegroup,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;gave you the best approach in DATA step.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 02:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394391#M66374</guid>
      <dc:creator>MINX</dc:creator>
      <dc:date>2017-09-09T02:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my if then statement working?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394397#M66376</link>
      <description>&lt;P&gt;Always end your PROC/DATA STEP with a RUN (or quit).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When creating new variables you need to explicitly tell SAS both what data set you're working with and what you're trying to create. This occurs within a DATA STEP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA &amp;lt;New&amp;gt;;&lt;/P&gt;
&lt;P&gt;SET &amp;lt;source&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;code to do stuff goes here - like if/then;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe theres a free ecourse available as well as numerous videos here&lt;/P&gt;
&lt;P&gt;&lt;A href="http://video.sas.com/#category/videos/how-to-tutorials" target="_blank"&gt;http://video.sas.com/#category/videos/how-to-tutorials&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 03:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394397#M66376</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-09T03:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my if then statement working?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394407#M66382</link>
      <description>&lt;P&gt;Note: avoid making&amp;nbsp;ambiguous age group definitions&amp;nbsp;(as it is in your example for q2=18)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Age groups 13-17 and 18-24;&lt;BR /&gt;if 13 &amp;lt;= q2 &amp;lt;&amp;nbsp; 18 then agegroup= 1;&lt;BR /&gt;if 18 &amp;lt;= q2 &amp;lt;= 24 then agegroup= 2;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 04:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394407#M66382</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-09-09T04:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my if then statement working?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394473#M66385</link>
      <description>&lt;P&gt;Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 21:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-isn-t-my-if-then-statement-working/m-p/394473#M66385</guid>
      <dc:creator>aliyahh</dc:creator>
      <dc:date>2017-09-09T21:04:35Z</dc:date>
    </item>
  </channel>
</rss>

