<?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: How to use if statement in sas XML in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740371#M231268</link>
    <description>Thanks Oligolas&lt;BR /&gt;Its with if statement and another one is with macro.&lt;BR /&gt;</description>
    <pubDate>Tue, 11 May 2021 04:35:58 GMT</pubDate>
    <dc:creator>Shantaram</dc:creator>
    <dc:date>2021-05-11T04:35:58Z</dc:date>
    <item>
      <title>How to use if statement in sas XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740142#M231142</link>
      <description>&lt;P&gt;I am trying to implement if condition inside XML file.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table transformed_data as&lt;BR /&gt;select * from mig_test.transformed_data;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set transformed_data;&lt;BR /&gt;file "$FSAGQS/BD/transfers2/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="UTF-8"?&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;/P&gt;&lt;P&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;Startdate&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;PolSTDT&amp;lt;/externalIdentifier&amp;gt;';&lt;BR /&gt;put '&amp;lt;/formQuestionRef&amp;gt;';&lt;BR /&gt;%if %superq(ID_01) ='' %then %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;%else %Do;&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' ID_01 +(-1) '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;%end;&lt;BR /&gt;put '&amp;lt;/applicationFormQuestion&amp;gt;';&lt;BR /&gt;put '&amp;lt;/applicationFormQuestionList&amp;gt;';&lt;BR /&gt;put '&amp;lt;/applicationFormGroup&amp;gt;';&lt;/P&gt;&lt;P&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;Productcode&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;externlIdentifier&amp;gt;ProductName&amp;lt;/externalIdentifier&amp;gt;';&lt;BR /&gt;put '&amp;lt;/formQuestionRef&amp;gt;';&lt;BR /&gt;%if ID_02 IS MISSING %then %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;%else %do;&lt;BR /&gt;put '&amp;lt;answer&amp;gt;';&lt;BR /&gt;put '&amp;lt;value&amp;gt;' ID_02 +(-1) '&amp;lt;/value&amp;gt;';&lt;BR /&gt;put '&amp;lt;/answer&amp;gt;';&lt;BR /&gt;%end;&lt;BR /&gt;put '&amp;lt;/applicationFormQuestion&amp;gt;';&lt;BR /&gt;put '&amp;lt;/applicationFormQuestionList&amp;gt;';&lt;BR /&gt;put '&amp;lt;/applicationFormGroup&amp;gt;';&lt;BR /&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>Mon, 10 May 2021 11:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740142#M231142</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-10T11:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use if statement in sas XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740194#M231160</link>
      <description>&lt;P&gt;You've posted the same question&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-pass-value-to-the-parameterized-macro-inside-sas-XML-Tags/m-p/740144#M231143" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 14:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740194#M231160</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-05-10T14:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use if statement in sas XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740371#M231268</link>
      <description>Thanks Oligolas&lt;BR /&gt;Its with if statement and another one is with macro.&lt;BR /&gt;</description>
      <pubDate>Tue, 11 May 2021 04:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740371#M231268</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2021-05-11T04:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use if statement in sas XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740407#M231286</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %superq(ID_01) ='' %then %Do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This condition will always be false, as the&amp;nbsp;&lt;EM&gt;text&lt;/EM&gt; ID_01 is always non equal to an empty string. Keep in mind that macro is a&amp;nbsp;&lt;STRONG&gt;pre&lt;/STRONG&gt;processor that works on code long before that&amp;nbsp; code is executed; therefore, macro statements will never have access to the content of data step variables.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 08:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740407#M231286</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-11T08:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use if statement in sas XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740412#M231290</link>
      <description>&lt;P&gt;I see,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so ID_01 is a numeric value from your dataset. In this case you do not need any macro code.&lt;/P&gt;
&lt;P&gt;what you want instead of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %superq(ID_01) ='' %then %Do;
put '&amp;lt;answer&amp;gt;';
put '&amp;lt;value/&amp;gt;';
put '&amp;lt;/answer&amp;gt;';
%End;
%else %Do;
put '&amp;lt;answer&amp;gt;';
put '&amp;lt;value&amp;gt;' ID_01 +(-1) '&amp;lt;/value&amp;gt;';
put '&amp;lt;/answer&amp;gt;';
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;may be this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(ID_01) then Do;
   put '&amp;lt;answer&amp;gt;';
   put '&amp;lt;value/&amp;gt;';
   put '&amp;lt;/answer&amp;gt;';
End;
else Do;
   put '&amp;lt;answer&amp;gt;';
   ID_01=ID_01+1;
   put '&amp;lt;value&amp;gt;' ID_01'&amp;lt;/value&amp;gt;';
   put '&amp;lt;/answer&amp;gt;';
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 May 2021 09:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-if-statement-in-sas-XML/m-p/740412#M231290</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-05-11T09:09:08Z</dc:date>
    </item>
  </channel>
</rss>

