<?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: Problem in adding new column with if else statement in Stored process in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353967#M82699</link>
    <description>&lt;P&gt;Hi, thx for the guide. I remove the RFFG= before the IF statement and changed from EFFG to RFFG.&lt;/P&gt;&lt;P&gt;However, RFFG is still not showing up. Could you guide me further?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My new code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data platformdata fulldata;
set platformdata2 (drop=System_Total_FG);
newcolumn=RFFG;
if System_Total_FG &amp;lt; 1974 then do;
	RFFG=0.8;
end;
else if System_Total_FG &amp;lt; 2011 then do;
	RFFG=0.81;
end;&lt;BR /&gt;
else if System_Total_FG &amp;lt; 2168 then do;
	RFFG=0.82;
end;
else if System_Total_FG &amp;lt; 2201 then do;
	RFFG=0.83;
end;
else if System_Total_FG &amp;lt; 2293 then do;
	RFFG=0.84;
end;
else RFFG = 0.85;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2017 03:33:56 GMT</pubDate>
    <dc:creator>imdickson</dc:creator>
    <dc:date>2017-04-27T03:33:56Z</dc:date>
    <item>
      <title>Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353961#M82695</link>
      <description>&lt;P&gt;Hi. I am trying to add a new column with if else statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data platformdata fulldata;
set platformdata2;
RFFG =if System_Total_FG &amp;lt; 1974 then do;
	RFFG=0.8;
end;
else if System_Total_FG &amp;lt; 2011 then do;
	RFFG=0.81;
end;
else if System_Total_FG &amp;lt; 2168 then do;
	RFFG=0.82;
end;
else if System_Total_FG &amp;lt; 2201 then do;
	RFFG=0.83;
end;
else if System_Total_FG &amp;lt; 2293 then do;
	RFFG=0.84;
end;
else EFFG = 0.85;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the result will not have a new column called RFFG. First of all, System_Total_FG is in one of the dataset and basically what i want is a new column showing the value based on the if else statement. What am i doing wrong?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 02:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353961#M82695</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-04-27T02:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353963#M82696</link>
      <description>&lt;P&gt;I also added a statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newcolumn=RFFG;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but in log file, im getting this:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8575i01E3C8D42E59CC20/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS Error.PNG" title="SAS Error.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 03:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353963#M82696</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-04-27T03:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353964#M82697</link>
      <description>&lt;P&gt;RFFG =if... is a syntax error. The correct syntax is IF &lt;EM&gt;condition&lt;/EM&gt; THEN &lt;EM&gt;statement&lt;/EM&gt;; Take the RFFG = part out. Also the last ELSE statement creates a new variable EFFG, I suspect you meant RFFG.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 03:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353964#M82697</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-27T03:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353967#M82699</link>
      <description>&lt;P&gt;Hi, thx for the guide. I remove the RFFG= before the IF statement and changed from EFFG to RFFG.&lt;/P&gt;&lt;P&gt;However, RFFG is still not showing up. Could you guide me further?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My new code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data platformdata fulldata;
set platformdata2 (drop=System_Total_FG);
newcolumn=RFFG;
if System_Total_FG &amp;lt; 1974 then do;
	RFFG=0.8;
end;
else if System_Total_FG &amp;lt; 2011 then do;
	RFFG=0.81;
end;&lt;BR /&gt;
else if System_Total_FG &amp;lt; 2168 then do;
	RFFG=0.82;
end;
else if System_Total_FG &amp;lt; 2201 then do;
	RFFG=0.83;
end;
else if System_Total_FG &amp;lt; 2293 then do;
	RFFG=0.84;
end;
else RFFG = 0.85;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 03:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353967#M82699</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-04-27T03:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353973#M82703</link>
      <description>&lt;P&gt;Correct and simplified code would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data platformdata fulldata;
set platformdata2;
if System_Total_FG &amp;lt; 1974 then RFFG=0.8;
else if System_Total_FG &amp;lt; 2011 then RFFG=0.81;
else if System_Total_FG &amp;lt; 2168 then RFFG=0.82;
else if System_Total_FG &amp;lt; 2201 then RFFG=0.83;
else if System_Total_FG &amp;lt; 2293 then RFFG=0.84;
else RFFG = 0.85;
drop System_Total_FG;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It will create two identical datasets (platformdata and fulldata) based on input dataset platformdata2. Variable system_total_fg will not be part of the output datasets.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 04:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353973#M82703</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-04-27T04:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353981#M82708</link>
      <description>&lt;P&gt;Hi There. Thx for the guide. It works. However, i want to add another column with a set of if else logic. I am getting error : No Matching IF ELSE Clause&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data platformdata2;/*fulldata*/
set platformdata2;/*(drop=System_Total_FG)*/
/*newcolumn=RFFG;*/
if System_Total_FG &amp;lt; 1974 then do;
	RFFG=0.8;
end;
else if System_Total_FG &amp;lt; 2011 then do;
	RFFG=0.81;
end;
else if System_Total_FG &amp;lt; 2168 then do;
	RFFG=0.82;
end;
else if System_Total_FG &amp;lt; 2201 then do;
	RFFG=0.83;
end;
else if System_Total_FG &amp;lt; 2293 then do;
	RFFG=0.84;
end;
else RFFG = 0.85;



if GPP_Nom &amp;lt; 1599 then do;
	RFGPP=0.8;
end;
else if GPP_NOM &amp;lt; 1649 then do;
	RFGPP=0.81;
end;
else if GPP_NOM &amp;lt;1799 then do;
	RFGPP=0.82;
end;
else if GPP_NOM &amp;lt; 1849 then do;
	RFGPP=0.83;
end;
else if GPP_NOM &amp;lt; 1949 then do;
	RFGPP=0.84;
else RFGPP=0.85;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May i know what is missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 05:13:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353981#M82708</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-04-27T05:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353993#M82713</link>
      <description>&lt;P&gt;You're missing an end:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if GPP_NOM &amp;lt; 1949 then do;
	RFGPP=0.84;
end; /* this was missing */
else RFGPP=0.85;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 06:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353993#M82713</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-27T06:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353995#M82714</link>
      <description>&lt;P&gt;PS since you never have more than one statement in your "then" branches, the do/end blocks are not necessary:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data platformdata2;/*fulldata*/
set platformdata2;/*(drop=System_Total_FG)*/

/*newcolumn=RFFG;*/
if System_Total_FG &amp;lt; 1974
then RFFG=0.8;
else if System_Total_FG &amp;lt; 2011
then RFFG=0.81;
else if System_Total_FG &amp;lt; 2168
then RFFG=0.82;
else if System_Total_FG &amp;lt; 2201
then RFFG=0.83;
else if System_Total_FG &amp;lt; 2293
then RFFG=0.84;
else RFFG = 0.85;

if GPP_Nom &amp;lt; 1599
then RFGPP=0.8;
else if GPP_NOM &amp;lt; 1649
then RFGPP=0.81;
else if GPP_NOM &amp;lt;1799
then RFGPP=0.82;
else if GPP_NOM &amp;lt; 1849
then RFGPP=0.83;
else if GPP_NOM &amp;lt; 1949
then RFGPP=0.84;
else RFGPP=0.85;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 06:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/353995#M82714</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-27T06:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/354001#M82720</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;: applying maxim 8 will simplify the code ...&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 07:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/354001#M82720</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-04-27T07:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/354005#M82722</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;: applying maxim 8 will simplify the code ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good catch!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 07:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/354005#M82722</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-27T07:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in adding new column with if else statement in Stored process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/354012#M82728</link>
      <description>&lt;P&gt;No love for select() clauses anymore?&lt;/P&gt;
&lt;PRE&gt;data platformdata2;
  set platformdata2;
  select(system_total_fg);
    when (&amp;lt; 1974) rffg=0.8;
    when (&amp;lt; 2011) rffg=0.81;
    ...
    otherwise rffg=0.85;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;You could probably do it simpler using format ranges also.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 08:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-adding-new-column-with-if-else-statement-in-Stored/m-p/354012#M82728</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-27T08:46:26Z</dc:date>
    </item>
  </channel>
</rss>

