<?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 formatted values in if condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558755#M10152</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having problem in passing fomatted values in if condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have below TRTP values in my count dataset:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29528iD69DC7DC3124BA0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture 1.PNG" alt="Capture 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to create another variable by using below calculation.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data count1;
	set count;
	if TRTP eq "A" then c2=count/Count1*100;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I am getting missing values for c2 variable, but log is clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anything I am missing there?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Adithya&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2019 20:04:30 GMT</pubDate>
    <dc:creator>chinna0369</dc:creator>
    <dc:date>2019-05-14T20:04:30Z</dc:date>
    <item>
      <title>formatted values in if condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558755#M10152</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having problem in passing fomatted values in if condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have below TRTP values in my count dataset:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29528iD69DC7DC3124BA0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture 1.PNG" alt="Capture 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to create another variable by using below calculation.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data count1;
	set count;
	if TRTP eq "A" then c2=count/Count1*100;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I am getting missing values for c2 variable, but log is clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anything I am missing there?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Adithya&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 20:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558755#M10152</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2019-05-14T20:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: formatted values in if condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558758#M10154</link>
      <description>&lt;P&gt;Your code compares TRTP to "A", but if TRTP is formatted, it may have underlying values different than what you see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any such comparison&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; TRTP &lt;SPAN class="token operator"&gt;eq&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"A"&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;uses the unformatted values, not the formatted values. So the comparison would fail, even if it LOOKS LIKE your variable TRTP has value "A".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So just to make up an example, if the format $TRT1. is something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value $trt "A","B","Q","T"="A";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then the comparison you would want to do is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if TRTP in ("A","B","Q","T")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 20:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558758#M10154</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-14T20:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: formatted values in if condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558762#M10156</link>
      <description>&lt;P&gt;To compare a value to a formatted value explicitly use the format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;If&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; put(trtp,&lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;$trt1.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;) = &lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'A' then &amp;lt;whatever&amp;gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 20:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558762#M10156</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-14T20:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: formatted values in if condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558776#M10158</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;To compare a value to a formatted value explicitly use the format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2" color="#0000ff"&gt;If&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; put(trtp,&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2" color="#804040"&gt;$trt1.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;) = &lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2" color="#800080"&gt;'A' then &amp;lt;whatever&amp;gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option is to use the format &lt;EM&gt;implicitly&lt;/EM&gt;:&lt;/P&gt;
&lt;PRE&gt;if &lt;STRONG&gt;vvalue(trtp)&lt;/STRONG&gt;='A' then ...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;(See &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p06uh7sqlh94nxn1gezyms3e9njn.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;VVALUE function&lt;/A&gt;. Be careful, however, when using this for unformatted numeric variables. In that case the default format &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1fum54c93f8r0n1wrs5mrb05nzi.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;BEST12.&lt;/A&gt; will apply.)&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 21:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatted-values-in-if-condition/m-p/558776#M10158</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-14T21:20:40Z</dc:date>
    </item>
  </channel>
</rss>

