<?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  Achieve the Digts after decimals based on a &amp;quot;Decimal&amp;quot; Varaiible in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913920#M360172</link>
    <description>&lt;P&gt;How about this one ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
number = 2;
symbol = '&amp;lt;=';
compare = 3;
output;
number = 2;
symbol = '&amp;gt;';
compare = 3;
output;
run;

data want;
set have;
want=ifc(resolve(cats('%sysevalf(',number,symbol,compare,',boolean)'))='1','Correct','Wrong  ');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Feb 2024 07:01:28 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-02-01T07:01:28Z</dc:date>
    <item>
      <title>How to  Achieve the Digts after decimals based on a "Decimal" Varaiible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913704#M360103</link>
      <description>&lt;P&gt;&amp;nbsp;I have the&amp;nbsp; following dataset with Variables:&lt;/P&gt;
&lt;P&gt;Have dataset:&lt;/P&gt;
&lt;P&gt;Number -&amp;gt; Indicated the Actual Numerical Values&lt;/P&gt;
&lt;P&gt;Dec&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt;Number of digits (numbers) after the decimals have to be displayed.&lt;/P&gt;
&lt;P&gt;Want Dataset:&lt;/P&gt;
&lt;P&gt;Number Char --&amp;gt; Character format of "Number" after the decimals&amp;nbsp; format applied.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data have;
 input Number dec ;
 cards;
 2.345  	2
 1.8    	1
 0      	2
 123.45   	1
 5.6781		2
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Want dataset: ( I&amp;nbsp; wrote the Numberchar ,rounding/&amp;nbsp; may have error)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1706662626869.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93085iBF6327CB606D9DC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1706662626869.png" alt="SASuserlot_0-1706662626869.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanks in Advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 00:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913704#M360103</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-01-31T00:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to  Achieve the Digts after decimals based on a "Decimal" Varaiible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913709#M360105</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input Number dec ;
 NumberChar = left(put(round(Number, 10 ** (-dec)), best12.));
cards;
2.345  2
1.8    1
0      2
123.45 1
5.6781 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2024 03:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913709#M360105</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-01-31T03:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to  Achieve the Digts after decimals based on a "Decimal" Varaiible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913712#M360108</link>
      <description>&lt;P&gt;Use the PUTN() function. That allows the format specification to be dynamically created.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Number dec ;
cards;
2.345   2
1.8     1
0       2
123.45  1
5.6781  2
;

data want;
  set have;
  length NumberChar $32 ;
  numberchar = left(putn(number,cats('32.',dec)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;                         Number
Obs     Number    dec     Char

 1       2.345     2     2.35
 2       1.800     1     1.8
 3       0.000     2     0.00
 4     123.450     1     123.5
 5       5.678     2     5.68

&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2024 04:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913712#M360108</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-31T04:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to  Achieve the Digts after decimals based on a "Decimal" Varaiible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913717#M360109</link>
      <description>&lt;P&gt;Thank you both&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;. Both options worked. I learned something new function. I appreciate it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@Tom, I have a similar question, but I'm not 100% sure how to ask the question.&amp;nbsp; I have the following dataset: "have." Is there any way&amp;nbsp; I can dynamically use the 'Symbol" variable to check "number" and "compare" and create a "CHECK" variable if the condition is correct or not?&lt;/P&gt;
&lt;P&gt;have: ( usually I have the data I read from xlsx sheet)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
number = 2;
symbol = '&amp;lt;=';
compare = 3;
output;
number = 2;
symbol = '&amp;gt;';
compare = 3;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1706681031449.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93087iEB8C95EA6ADDAD44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1706681031449.png" alt="SASuserlot_0-1706681031449.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Want:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_1-1706681063614.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93088iD56840228B1767EC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_1-1706681063614.png" alt="SASuserlot_1-1706681063614.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 06:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913717#M360109</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-01-31T06:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to  Achieve the Digts after decimals based on a "Decimal" Varaiible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913846#M360138</link>
      <description>&lt;P&gt;I suggest if you are going to go down this route that you do not use "symbols" but the mnemonic comparison operators such as EQ NE LT LE GT GE. It may be entirely too easy to get a unicode symbol that will not resolve to a valid comparison character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach may work depending just how much junk you are going to attempt with this.&lt;/P&gt;
&lt;PRE&gt;data junk;
  set have;
  select (symbol);
   when ('&amp;lt;=') result= number le compare;
   when ('&amp;gt;') result= number gt compare;&lt;BR /&gt;   otherwise;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Result will be the typical 1 for true and 0 for false. I won't make any evaluation about "right" or "wrong" based on such logic. It would require a WHEN clause for each separate comparison you expect to do. If you do use the EQ NE etc I would suggest using Select (upcase(symbol)) to reduce the number of possibly entries in each When. When will use multiple choices or conditions separated by comma.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 16:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913846#M360138</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-31T16:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to  Achieve the Digts after decimals based on a "Decimal" Varaiible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913920#M360172</link>
      <description>&lt;P&gt;How about this one ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
number = 2;
symbol = '&amp;lt;=';
compare = 3;
output;
number = 2;
symbol = '&amp;gt;';
compare = 3;
output;
run;

data want;
set have;
want=ifc(resolve(cats('%sysevalf(',number,symbol,compare,',boolean)'))='1','Correct','Wrong  ');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2024 07:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Achieve-the-Digts-after-decimals-based-on-a-quot-Decimal/m-p/913920#M360172</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-01T07:01:28Z</dc:date>
    </item>
  </channel>
</rss>

