<?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: Formatted variable does not work in conditional statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/488044#M127201</link>
    <description>&lt;P&gt;Thank you! That is ingenious!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 19 Aug 2018 03:10:03 GMT</pubDate>
    <dc:creator>lydiawawa</dc:creator>
    <dc:date>2018-08-19T03:10:03Z</dc:date>
    <item>
      <title>Formatted variable does not work in conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/487803#M127120</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a format file that names the levels of categorical variables "workcode". The format value code is $workload.&lt;/P&gt;&lt;P&gt;Following is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data df; 
     set df1;
     format workcode $workload30. ;
     if workcode = "Other" then delete ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I want to delete all other variables assigned by the format statement as "Other" in the separate format file. However, the datastep doesn't seem to recognize the condition statement right after format. No delete action was performed. Does anyone know what caused the issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 15:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/487803#M127120</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2018-08-17T15:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Formatted variable does not work in conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/487812#M127124</link>
      <description>&lt;P&gt;Since We do not have a sample of your data, I am assuming this may help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; df&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
     &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; df1&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;     new_workcode=put(workcode,$workload30.);
     *&lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; workcode &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;workload30&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
     &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; new_workcode&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"Other"&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;delete&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Aug 2018 15:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/487812#M127124</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-17T15:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Formatted variable does not work in conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/487814#M127125</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt;&amp;nbsp; put(workcode,$workload30.) &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"Other"&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;delete&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variables always maintain their value and that is used for comparisons. For formatted values you have to explicitly create the formatted value. Note that you may create a value that still doesn't compare as expected if the format includes leading spaces.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 15:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/487814#M127125</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-17T15:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Formatted variable does not work in conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/488044#M127201</link>
      <description>&lt;P&gt;Thank you! That is ingenious!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 03:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatted-variable-does-not-work-in-conditional-statement/m-p/488044#M127201</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2018-08-19T03:10:03Z</dc:date>
    </item>
  </channel>
</rss>

