<?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 within if condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742360#M232191</link>
    <description>Hi KurtBremser,&lt;BR /&gt;In first row there is a value tosst po&amp;amp;ice of column DC_ID19. when we are executing&lt;BR /&gt;if &amp;amp;DC_ID. not in('.',' ') then Do;&lt;BR /&gt;if compress(&amp;amp;DC_ID.,'% &amp;lt;&amp;gt;&amp;amp;', 'k') ='&amp;amp;' then Do;/*Output of this code is &amp;amp; */&lt;BR /&gt;IF the output is &amp;amp; then it should display following output&lt;BR /&gt;put '&amp;lt;![CDATA[';&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. +(-1) '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;put ']]&amp;gt;';&lt;BR /&gt;But its not executing the particular code patch.</description>
    <pubDate>Wed, 19 May 2021 09:27:59 GMT</pubDate>
    <dc:creator>Shantaram</dc:creator>
    <dc:date>2021-05-19T09:27:59Z</dc:date>
    <item>
      <title>If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742333#M232173</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write if condition inside first if condition.&lt;/P&gt;&lt;P&gt;Sample code.&lt;BR /&gt;data transformed_data;&lt;BR /&gt;input DC_014 $6. DC_019 $13. DC_035 $9.;&lt;BR /&gt;cards;&lt;BR /&gt;116312 tosst po&amp;amp;ice&lt;BR /&gt;118323 tosst Police Mobile&lt;BR /&gt;113244 tosst Police Mobile&lt;BR /&gt;115333 tosst Police Mobile&lt;BR /&gt;118333 tosst Police Mobile&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%macro file_loop(DC_ID);&lt;BR /&gt;if &amp;amp;DC_ID. not in('.',' ') then Do;&lt;BR /&gt;if compress(&amp;amp;DC_ID., '% &amp;lt;&amp;gt;&amp;amp;', 'k') in ('&amp;amp;') then Do;&lt;BR /&gt;put '&amp;lt;![CDATA[';&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. +(-1) '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;put ']]&amp;gt;';&lt;BR /&gt;End;&lt;BR /&gt;else Do;&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;end;&lt;BR /&gt;End;&lt;BR /&gt;else Do;&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value/&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;end;&lt;BR /&gt;%mend file_loop;&lt;/P&gt;&lt;P&gt;options mprint mlogic symbolgen;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set transformed_data;&lt;BR /&gt;file "c:/TEST_Shan1.xml";&lt;BR /&gt;if _n_=1 then&lt;BR /&gt;do;&lt;BR /&gt;put '&amp;lt;?xml version="1.0" encoding="iso-8859-1"?&amp;gt;';&lt;BR /&gt;put '&amp;lt;soapenv:Envelope xmlns:soapenv="&lt;A href="http://schemas.xmlsoap.org/soap/envelope/" target="_blank"&gt;http://schemas.xmlsoap.org/soap/envelope/&lt;/A&gt;" xmlns:type="&lt;A href="http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type" target="_blank"&gt;http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type&lt;/A&gt;"&amp;gt;';&lt;BR /&gt;put '&amp;lt;soapenv:Header /&amp;gt;';&lt;BR /&gt;put '&amp;lt;soapenv:Body&amp;gt;';&lt;BR /&gt;put '&amp;lt;handlePolicyApplicationRequest&amp;gt;';&lt;BR /&gt;put '&amp;lt;policyRequest&amp;gt;';&lt;BR /&gt;/*Code*/&lt;BR /&gt;Put '&amp;lt;applicationForm&amp;gt;';&lt;BR /&gt;Put '&amp;lt;applicationFormGroupList&amp;gt;';&lt;BR /&gt;put '&amp;lt;applicationFormGroup&amp;gt;';&lt;BR /&gt;put '&amp;lt;formGroupRef&amp;gt;';&lt;BR /&gt;put '&amp;lt;externalIdentifier&amp;gt;polGenStartdate&amp;lt;/externalIdentifier&amp;gt;';&lt;BR /&gt;put '&amp;lt;/formGroupRef&amp;gt;';&lt;BR /&gt;put '&amp;lt;applicationFormQuestionList&amp;gt;';&lt;BR /&gt;put '&amp;lt;applicationFormQuestion&amp;gt;';&lt;BR /&gt;put '&amp;lt;formQuestionRef&amp;gt;';&lt;BR /&gt;put '&amp;lt;externalIdentifier&amp;gt;Pol1&amp;lt;/externalIdentifier&amp;gt;';&lt;BR /&gt;put '&amp;lt;/formQuestionRef&amp;gt;';&lt;BR /&gt;%file_loop(DC_014);&lt;BR /&gt;put '&amp;lt;/applicationFormQuestionList&amp;gt;';&lt;BR /&gt;put '&amp;lt;formQuestionRef&amp;gt;';&lt;BR /&gt;put '&amp;lt;externalIdentifier&amp;gt;pol&amp;lt;/externalIdentifier&amp;gt;';&lt;BR /&gt;put '&amp;lt;/formQuestionRef&amp;gt;';&lt;BR /&gt;%file_loop(DC_019);&lt;BR /&gt;put '&amp;lt;/applicationFormQuestionList&amp;gt;';&lt;BR /&gt;put '&amp;lt;formQuestionRef&amp;gt;';&lt;BR /&gt;put '&amp;lt;externalIdentifier&amp;gt;pol&amp;lt;/externalIdentifier&amp;gt;';&lt;BR /&gt;put '&amp;lt;/formQuestionRef&amp;gt;';&lt;BR /&gt;%file_loop(DC_035);&lt;BR /&gt;put '&amp;lt;/applicationFormQuestionList&amp;gt;';&lt;/P&gt;&lt;P&gt;put '&amp;lt;/applicationFormGroup&amp;gt;';&lt;BR /&gt;put '&amp;lt;/applicationFormGroupList&amp;gt;';&lt;BR /&gt;put '&amp;lt;/applicationForm&amp;gt;';&lt;BR /&gt;put '&amp;lt;/policyRequest&amp;gt;';&lt;BR /&gt;put '&amp;lt;/handlePolicyApplicationRequest&amp;gt;';&lt;BR /&gt;put '&amp;lt;/soapenv:Body&amp;gt;';&lt;BR /&gt;put '&amp;lt;/soapenv:Envelope&amp;gt;';&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 06:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742333#M232173</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-19T06:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742339#M232179</link>
      <description>&lt;P&gt;Your macro misses the END for the outer DO block.&lt;/P&gt;
&lt;P&gt;If you had used proper code formatting (consistent indentation for functional blocks, see Maxim 12), this would have been obvious.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 06:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742339#M232179</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-19T06:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742357#M232188</link>
      <description>&lt;P&gt;I have to correct myself, there are enough ENDs, but it needed consistent formatting for me to find this out:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro file_loop(DC_ID);
if &amp;amp;DC_ID. not in ('.',' ')
then do;
  if compress(&amp;amp;DC_ID., '% &amp;lt;&amp;gt;&amp;amp;', 'k') in ('&amp;amp;')
  then do;
    put '&amp;lt;![CDATA[';
    put '&amp;lt;answer&amp;gt;';
    put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. +(-1) '&amp;lt;/value&amp;gt;';
    put '&amp;lt;/answer&amp;gt;';
    put ']]&amp;gt;';
  end;
  else do;
    put '&amp;lt;answer&amp;gt;';
    put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. '&amp;lt;/value&amp;gt;';
    put '&amp;lt;/answer&amp;gt;';
  end;
end;
else do;
  put '&amp;lt;answer&amp;gt;';
  put '&amp;lt;value/&amp;gt;';
  put '&amp;lt;/answer&amp;gt;';
end;
%mend file_loop;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since this complete code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data transformed_data;
input DC_014 $6. DC_019 $13. DC_035 $9.;
cards;
116312 tosst po&amp;amp;ice
118323 tosst Police Mobile
113244 tosst Police Mobile
115333 tosst Police Mobile
118333 tosst Police Mobile
;

%macro file_loop(DC_ID);
if &amp;amp;DC_ID. not in ('.',' ')
then do;
  if compress(&amp;amp;DC_ID., '% &amp;lt;&amp;gt;&amp;amp;', 'k') in ('&amp;amp;')
  then do;
    put '&amp;lt;![CDATA[';
    put '&amp;lt;answer&amp;gt;';
    put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. +(-1) '&amp;lt;/value&amp;gt;';
    put '&amp;lt;/answer&amp;gt;';
    put ']]&amp;gt;';
  end;
  else do;
    put '&amp;lt;answer&amp;gt;';
    put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. '&amp;lt;/value&amp;gt;';
    put '&amp;lt;/answer&amp;gt;';
  end;
end;
else do;
  put '&amp;lt;answer&amp;gt;';
  put '&amp;lt;value/&amp;gt;';
  put '&amp;lt;/answer&amp;gt;';
end;
%mend file_loop;

data _null_;
set transformed_data;
file "/folders/myfolders/TEST_Shan1.xml";
if _n_ = 1
then do;
  put '&amp;lt;?xml version="1.0" encoding="iso-8859-1"?&amp;gt;';
  put '&amp;lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:type="http://www.quinity.com/qis/soap/qisxmlpolicyrequestservice/type"&amp;gt;';
  put '&amp;lt;soapenv:Header /&amp;gt;';
  put '&amp;lt;soapenv:Body&amp;gt;';
  put '&amp;lt;handlePolicyApplicationRequest&amp;gt;';
  put '&amp;lt;policyRequest&amp;gt;';
  /*Code*/
  put '&amp;lt;applicationForm&amp;gt;';
  put '&amp;lt;applicationFormGroupList&amp;gt;';
  put '&amp;lt;applicationFormGroup&amp;gt;';
  put '&amp;lt;formGroupRef&amp;gt;';
  put '&amp;lt;externalIdentifier&amp;gt;polGenStartdate&amp;lt;/externalIdentifier&amp;gt;';
  put '&amp;lt;/formGroupRef&amp;gt;';
  put '&amp;lt;applicationFormQuestionList&amp;gt;';
  put '&amp;lt;applicationFormQuestion&amp;gt;';
  put '&amp;lt;formQuestionRef&amp;gt;';
  put '&amp;lt;externalIdentifier&amp;gt;Pol1&amp;lt;/externalIdentifier&amp;gt;';
  put '&amp;lt;/formQuestionRef&amp;gt;';
  %file_loop(DC_014);
  put '&amp;lt;/applicationFormQuestionList&amp;gt;';
  put '&amp;lt;formQuestionRef&amp;gt;';
  put '&amp;lt;externalIdentifier&amp;gt;pol&amp;lt;/externalIdentifier&amp;gt;';
  put '&amp;lt;/formQuestionRef&amp;gt;';
  %file_loop(DC_019);
  put '&amp;lt;/applicationFormQuestionList&amp;gt;';
  put '&amp;lt;formQuestionRef&amp;gt;';
  put '&amp;lt;externalIdentifier&amp;gt;pol&amp;lt;/externalIdentifier&amp;gt;';
  put '&amp;lt;/formQuestionRef&amp;gt;';
  %file_loop(DC_035);
  put '&amp;lt;/applicationFormQuestionList&amp;gt;';
  put '&amp;lt;/applicationFormGroup&amp;gt;';
  put '&amp;lt;/applicationFormGroupList&amp;gt;';
  put '&amp;lt;/applicationForm&amp;gt;';
  put '&amp;lt;/policyRequest&amp;gt;';
  put '&amp;lt;/handlePolicyApplicationRequest&amp;gt;';
  put '&amp;lt;/soapenv:Body&amp;gt;';
  put '&amp;lt;/soapenv:Envelope&amp;gt;';
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;worked without problems, what is your issue? Please describe it, if your log contains any WARNINGs, ERRORs or extraneous NOTEs, post it.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 09:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742357#M232188</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-19T09:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742360#M232191</link>
      <description>Hi KurtBremser,&lt;BR /&gt;In first row there is a value tosst po&amp;amp;ice of column DC_ID19. when we are executing&lt;BR /&gt;if &amp;amp;DC_ID. not in('.',' ') then Do;&lt;BR /&gt;if compress(&amp;amp;DC_ID.,'% &amp;lt;&amp;gt;&amp;amp;', 'k') ='&amp;amp;' then Do;/*Output of this code is &amp;amp; */&lt;BR /&gt;IF the output is &amp;amp; then it should display following output&lt;BR /&gt;put '&amp;lt;![CDATA[';&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. +(-1) '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;put ']]&amp;gt;';&lt;BR /&gt;But its not executing the particular code patch.</description>
      <pubDate>Wed, 19 May 2021 09:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742360#M232191</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-19T09:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742364#M232195</link>
      <description>&lt;P&gt;Run this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
set transformed_data;
x1 = put(compress(DC_019, '% &amp;lt;&amp;gt;&amp;amp;', 'k'),$hex26.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you will see that the result of the COMPRESS function starts with a blank.&lt;/P&gt;
&lt;P&gt;Why?&lt;/P&gt;
&lt;P&gt;You read with formatted input, so the blanks between the columns end up as leading blanks in the strings.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 09:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742364#M232195</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-19T09:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742365#M232196</link>
      <description>i want only special character from string Ex. in tosst po&amp;amp;ice there is &amp;amp; is a special character. If their is a special character in the string then i have to execute&lt;BR /&gt;put '&amp;lt;![CDATA[';&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' &amp;amp;DC_ID. +(-1) '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;put ']]&amp;gt;';</description>
      <pubDate>Wed, 19 May 2021 09:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742365#M232196</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-19T09:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742368#M232198</link>
      <description>&lt;P&gt;If you want to get rid of blanks, compress them out of the string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if compress(&amp;amp;DC_ID., '%&amp;lt;&amp;gt;&amp;amp;', 'k') in ('&amp;amp;')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By having a blank in the second argument of the COMPRESS function, you kept them.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 10:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742368#M232198</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-19T10:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742369#M232199</link>
      <description>&lt;P&gt;And if you only want to check for the presence of a single special character in the string, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if indexc(&amp;amp;DC_ID.,'&amp;amp;')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 May 2021 10:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742369#M232199</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-19T10:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742372#M232202</link>
      <description>&lt;BR /&gt;if compress(&amp;amp;DC_ID., '%&amp;lt;&amp;gt;&amp;amp;','k') in ('&amp;amp;')&lt;BR /&gt;I want to write like this DC_019='&amp;amp;' then execute below part, space is not required any where. Only special character required from string EX.poli&amp;amp;ce output= &amp;amp;.</description>
      <pubDate>Wed, 19 May 2021 10:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742372#M232202</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-19T10:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742373#M232203</link>
      <description>&lt;P&gt;See my previous post using the INDEXC function. It does exactly what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 10:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742373#M232203</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-19T10:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: If within if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742376#M232205</link>
      <description>Hi KurtBremser,&lt;BR /&gt;&lt;BR /&gt;Its working.&lt;BR /&gt;Thank you so much.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shantaram.</description>
      <pubDate>Wed, 19 May 2021 11:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-within-if-condition/m-p/742376#M232205</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-19T11:14:44Z</dc:date>
    </item>
  </channel>
</rss>

