<?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 nested if statement in SAS not working as expected in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/nested-if-statement-in-SAS-not-working-as-expected/m-p/651835#M195603</link>
    <description>&lt;P&gt;Hi All even thogh memid is having name as sasadministartors iam getting incorrect value as vv instead of SAS Administrators if i use nested if not=&lt;/P&gt;&lt;P&gt;syntax,please help&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
	set work.groupmempersons_info(where=(memid='xxxxxxxxx'));
	length desc $255;
	call missing (desc);
	if memName = "sasadm" or memname = "sasevs" or memname = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping.";
else 
if Name= :'SASAdministrators' or Name= :'DI Developers'  then desc='SAS Administrator';
if Name not= :'XXX' and Name not=:'YYY' then desc='vv';
;
		rc=metadata_setattr("omsobj:person\"||memid,"Desc",desc);

                        
    put rc=;
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 29 May 2020 18:57:31 GMT</pubDate>
    <dc:creator>JJP1</dc:creator>
    <dc:date>2020-05-29T18:57:31Z</dc:date>
    <item>
      <title>nested if statement in SAS not working as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-if-statement-in-SAS-not-working-as-expected/m-p/651835#M195603</link>
      <description>&lt;P&gt;Hi All even thogh memid is having name as sasadministartors iam getting incorrect value as vv instead of SAS Administrators if i use nested if not=&lt;/P&gt;&lt;P&gt;syntax,please help&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
	set work.groupmempersons_info(where=(memid='xxxxxxxxx'));
	length desc $255;
	call missing (desc);
	if memName = "sasadm" or memname = "sasevs" or memname = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping.";
else 
if Name= :'SASAdministrators' or Name= :'DI Developers'  then desc='SAS Administrator';
if Name not= :'XXX' and Name not=:'YYY' then desc='vv';
;
		rc=metadata_setattr("omsobj:person\"||memid,"Desc",desc);

                        
    put rc=;
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 May 2020 18:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-if-statement-in-SAS-not-working-as-expected/m-p/651835#M195603</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2020-05-29T18:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: nested if statement in SAS not working as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/nested-if-statement-in-SAS-not-working-as-expected/m-p/651837#M195605</link>
      <description>&lt;P&gt;This statement:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;if Name not= :'XXX' and Name not=:'YYY' then desc='vv';&lt;/LI-CODE&gt;
&lt;P&gt;Is always executed regardless of what happened with the earlier if. &lt;/P&gt;
&lt;P&gt;I think you want:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data t;
	set work.groupmempersons_info(where=(memid='xxxxxxxxx'));
	length desc $255;
	call missing (desc);
	if memName = "sasadm" or memname = "sasevs" or memname = "sastrust" then put "Account is sasadm, sasevs or sastrust, skipping.";
else /* &amp;lt;= this else only effects the next statement*/
if Name= :'SASAdministrators' or Name= :'DI Developers'  then desc='SAS Administrator';
ELSE if Name not= :'XXX' and Name not=:'YYY' then desc='vv';
;
		rc=metadata_setattr("omsobj:person\"||memid,"Desc",desc);

                        
    put rc=;
	run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 19:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/nested-if-statement-in-SAS-not-working-as-expected/m-p/651837#M195605</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-29T19:04:21Z</dc:date>
    </item>
  </channel>
</rss>

