<?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 find last digit of non-integer variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639091#M21649</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to find the last digit after the decimal place of the non-integer variable in SAS 9.4.&lt;/P&gt;&lt;P&gt;e.g. I would like the last digit of 1.48 to show up as 8&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;infile datalines flowover;&lt;BR /&gt;input cohort id t1_trial1 t1_trial2 t1_trial3 t2_trial1 t2_trial2 t2_trial3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 30 1.6054 1.48 1.675 1.88 1.905 2.015&lt;BR /&gt;1 31 2.235 1.605 1.64 1.81 1.815 1.855&lt;BR /&gt;1 32 3.87 3.075 3.06 3.295 3.18 3.155&lt;BR /&gt;1 55 2.76 2.535 2.97 2.76 2.7 3.275&lt;BR /&gt;1 56 3.945 3.075 3.065 5.835 4.89 4.5459&lt;BR /&gt;1 67 2.05 1.945 1.56 3.015 3.005 3.135&lt;BR /&gt;1 76 1.65 2.165 1.87 2.99 2.22 2.5&lt;BR /&gt;;;;;&lt;BR /&gt;proc print; run;&lt;/P&gt;&lt;P&gt;/*I tried the following but no success */&lt;BR /&gt;data test2;&lt;BR /&gt;set test;&lt;/P&gt;&lt;P&gt;array l1 t1_trial1 - t1_trial3;&lt;BR /&gt;array l2 t2_trial1 - t2_trial3;&lt;BR /&gt;do over;&lt;BR /&gt;last1 = substr(l1, 1, length(l1)-1);&lt;BR /&gt;last2 = substr(l2, 1,length(l2)-1);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would appreciate some help!&lt;/P&gt;&lt;P&gt;Margaret&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Apr 2020 22:48:19 GMT</pubDate>
    <dc:creator>urban58</dc:creator>
    <dc:date>2020-04-10T22:48:19Z</dc:date>
    <item>
      <title>find last digit of non-integer variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639091#M21649</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to find the last digit after the decimal place of the non-integer variable in SAS 9.4.&lt;/P&gt;&lt;P&gt;e.g. I would like the last digit of 1.48 to show up as 8&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;infile datalines flowover;&lt;BR /&gt;input cohort id t1_trial1 t1_trial2 t1_trial3 t2_trial1 t2_trial2 t2_trial3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 30 1.6054 1.48 1.675 1.88 1.905 2.015&lt;BR /&gt;1 31 2.235 1.605 1.64 1.81 1.815 1.855&lt;BR /&gt;1 32 3.87 3.075 3.06 3.295 3.18 3.155&lt;BR /&gt;1 55 2.76 2.535 2.97 2.76 2.7 3.275&lt;BR /&gt;1 56 3.945 3.075 3.065 5.835 4.89 4.5459&lt;BR /&gt;1 67 2.05 1.945 1.56 3.015 3.005 3.135&lt;BR /&gt;1 76 1.65 2.165 1.87 2.99 2.22 2.5&lt;BR /&gt;;;;;&lt;BR /&gt;proc print; run;&lt;/P&gt;&lt;P&gt;/*I tried the following but no success */&lt;BR /&gt;data test2;&lt;BR /&gt;set test;&lt;/P&gt;&lt;P&gt;array l1 t1_trial1 - t1_trial3;&lt;BR /&gt;array l2 t2_trial1 - t2_trial3;&lt;BR /&gt;do over;&lt;BR /&gt;last1 = substr(l1, 1, length(l1)-1);&lt;BR /&gt;last2 = substr(l2, 1,length(l2)-1);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would appreciate some help!&lt;/P&gt;&lt;P&gt;Margaret&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 22:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639091#M21649</guid>
      <dc:creator>urban58</dc:creator>
      <dc:date>2020-04-10T22:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: find last digit of non-integer variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639094#M21650</link>
      <description>&lt;P&gt;Reading your data as character is the way to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input cohort id $ t1_trial1 $ t1_trial2 $ t1_trial3 $ t2_trial1 $ t2_trial2 $ t2_trial3 $;
datalines;
1 30 1.6054 1.48 1.675 1.88 1.905 2.015
1 31 2.235 1.605 1.64 1.81 1.815 1.855
1 32 3.87 3.075 3.06 3.295 3.18 3.155
1 55 2.76 2.535 2.97 2.76 2.7 3.275
1 56 3.945 3.075 3.065 5.835 4.89 4.5459
1 67 2.05 1.945 1.56 3.015 3.005 3.135
1 76 1.65 2.165 1.87 2.99 2.22 2.5
;
run;

data test2;
set test;
array trials t1_trial1 - t1_trial3 t2_trial1 - t2_trial3;
array last_digits $ last_digit1 - last_digit6;
do i = 1 to dim(trials);
 last_digits(i) = first(reverse(trim(trials(i))));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Apr 2020 23:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639094#M21650</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-04-10T23:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: find last digit of non-integer variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639102#M21654</link>
      <description>Thank you so much for the speedy reply, it worked great!&lt;BR /&gt;Much appreciated&lt;BR /&gt;</description>
      <pubDate>Sat, 11 Apr 2020 00:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/find-last-digit-of-non-integer-variable/m-p/639102#M21654</guid>
      <dc:creator>urban58</dc:creator>
      <dc:date>2020-04-11T00:33:43Z</dc:date>
    </item>
  </channel>
</rss>

