<?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: IF THEN in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52610#M2418</link>
    <description>Curious how this post fits into the Statistical Procedures forum?&lt;BR /&gt;
&lt;BR /&gt;
Suggest you get rid of the macro and get your standalone SAS DATA step working before making it more flexible with macro language elements.  Substitute constants (or if absolutely necessary use static macro variables).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Mon, 18 Apr 2011 22:51:00 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2011-04-18T22:51:00Z</dc:date>
    <item>
      <title>IF THEN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52606#M2414</link>
      <description>Hi,&lt;BR /&gt;
I was wondering why my code does not work. &lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA QMATRIX;&lt;BR /&gt;
SET QMATRIX;&lt;BR /&gt;
array itematt(3);&lt;BR /&gt;
do i=1 to 3;&lt;BR /&gt;
IF ITEM=1 THEN itematt&amp;amp;i=1;&lt;BR /&gt;
END;&lt;BR /&gt;
drop i;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
180: LINE and COLUMN cannot be determined.&lt;BR /&gt;
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where&lt;BR /&gt;
      the error has occurred.&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
MPRINT(MISQMATRIX):   data qmatrix;&lt;BR /&gt;
MPRINT(MISQMATRIX):   set qmatrix;&lt;BR /&gt;
MPRINT(MISQMATRIX):   IF ITEM=1 THEN itematt1-itematt3=1 ;&lt;BR /&gt;
MPRINT(MISQMATRIX):   Run;&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.QMATRIX may be incomplete.  When this step was stopped there were 0&lt;BR /&gt;
         observations and 4 variables.&lt;BR /&gt;
WARNING: Data set WORK.QMATRIX was not replaced because this step was stopped.</description>
      <pubDate>Mon, 18 Apr 2011 18:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52606#M2414</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-04-18T18:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52607#M2415</link>
      <description>The log reports that your if statement resolves to:&lt;BR /&gt;
&amp;gt; IF ITEM=1 THEN itematt1-itematt3=1 ;&lt;BR /&gt;
which is incorrect.</description>
      <pubDate>Mon, 18 Apr 2011 18:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52607#M2415</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2011-04-18T18:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52608#M2416</link>
      <description>thanks, I changed the syntax to this and still it does not run.&lt;BR /&gt;
&lt;BR /&gt;
%macro MISQMATRIX;&lt;BR /&gt;
%let num_skills=3;&lt;BR /&gt;
&lt;BR /&gt;
DATA Q_MATRIX_WR;&lt;BR /&gt;
set QMatrix;&lt;BR /&gt;
array skills(&amp;amp;num_skills);&lt;BR /&gt;
&lt;BR /&gt;
do i=1 to &amp;amp;num_skills;&lt;BR /&gt;
IF question=1 THEN skills1=1 skills2=1 skills3=1;&lt;BR /&gt;
ELSE&lt;BR /&gt;
skills(i)=1- skills(i);&lt;BR /&gt;
END;&lt;BR /&gt;
drop i;&lt;BR /&gt;
run; &lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
ERROR:&lt;BR /&gt;
NOTE 137-205: Line generated by the invoked macro "MISQMATRIX".&lt;BR /&gt;
1       DATA Q_MATRIX_WR; set QMatrix; array skills(&amp;amp;num_skills);  do i=1 to &amp;amp;num_skills; IF&lt;BR /&gt;
1    ! question=1 THEN skills1=1 skills2=1 skills3=1; ELSE skills(i)=1- skills(i); END; drop i;&lt;BR /&gt;
                                 -------&lt;BR /&gt;
                                 22&lt;BR /&gt;
1    ! run;&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=,&lt;BR /&gt;
              &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,&lt;BR /&gt;
              |, ||, ~=.&lt;BR /&gt;
&lt;BR /&gt;
MPRINT(MISQMATRIX):   do i=1 to 3;&lt;BR /&gt;
NOTE 137-205: Line generated by the invoked macro "MISQMATRIX".&lt;BR /&gt;
1       DATA Q_MATRIX_WR; set QMatrix; array skills(&amp;amp;num_skills);  do i=1 to &amp;amp;num_skills; IF&lt;BR /&gt;
1    ! question=1 THEN skills1=1 skills2=1 skills3=1; ELSE skills(i)=1- skills(i); END; drop i;&lt;BR /&gt;
                                           -------&lt;BR /&gt;
                                           22&lt;BR /&gt;
1    ! run;&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=,&lt;BR /&gt;
              &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,&lt;BR /&gt;
              |, ||, ~=.&lt;BR /&gt;
&lt;BR /&gt;
MPRINT(MISQMATRIX):   IF question=1 THEN skills1=1 skills2=1 skills3=1 ;&lt;BR /&gt;
MPRINT(MISQMATRIX):   ELSE skills(i)=1- skills(i);&lt;BR /&gt;
MPRINT(MISQMATRIX):   END;&lt;BR /&gt;
MPRINT(MISQMATRIX):   drop i;&lt;BR /&gt;
MPRINT(MISQMATRIX):   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.Q_MATRIX_WR may be incomplete.  When this step was stopped there were&lt;BR /&gt;
         0 observations and 4 variables.</description>
      <pubDate>Mon, 18 Apr 2011 19:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52608#M2416</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-04-18T19:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52609#M2417</link>
      <description>You are mixing up array syntax and macro syntax.&lt;BR /&gt;
&lt;BR /&gt;
array itematt(3);&lt;BR /&gt;
do i=1 to 3;&lt;BR /&gt;
IF ITEM=1 THEN itematt&amp;amp;i=1;&lt;BR /&gt;
END;&lt;BR /&gt;
uses the macro variable "i" (undefined), as well as an incorrect type of "container" on the ARRAY statement itself.&lt;BR /&gt;
&lt;BR /&gt;
Change the syntax &lt;BR /&gt;
array itematt{3};&lt;BR /&gt;
do i=1 to 3;&lt;BR /&gt;
IF ITEM=1 THEN itematt{i}=1;&lt;BR /&gt;
END;&lt;BR /&gt;
Note the {...} "container".</description>
      <pubDate>Mon, 18 Apr 2011 19:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52609#M2417</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-04-18T19:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52610#M2418</link>
      <description>Curious how this post fits into the Statistical Procedures forum?&lt;BR /&gt;
&lt;BR /&gt;
Suggest you get rid of the macro and get your standalone SAS DATA step working before making it more flexible with macro language elements.  Substitute constants (or if absolutely necessary use static macro variables).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 18 Apr 2011 22:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52610#M2418</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-04-18T22:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52611#M2419</link>
      <description>Thank you Doc, It is always great to read constructive comment vs. criticism of our lack of knowledge.</description>
      <pubDate>Tue, 19 Apr 2011 16:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/IF-THEN/m-p/52611#M2419</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-04-19T16:11:36Z</dc:date>
    </item>
  </channel>
</rss>

