<?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: extract last 10 digits in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937349#M368308</link>
    <description>&lt;P&gt;I don't accept your restrictions, and so it is easy to do. No reason to make it harder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, use the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_self"&gt;SCAN function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;last_10=scan(phone,3,' ');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Jul 2024 14:25:20 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-07-27T14:25:20Z</dc:date>
    <item>
      <title>extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937347#M368306</link>
      <description>&lt;P&gt;Hi Experts&lt;/P&gt;
&lt;P&gt;How to extract last 10 digits without substr ,scan ,reverse ,regex functions&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  dsn;
input phone $ 50.;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Jul 2024 12:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937347#M368306</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-07-27T12:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937349#M368308</link>
      <description>&lt;P&gt;I don't accept your restrictions, and so it is easy to do. No reason to make it harder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, use the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_self"&gt;SCAN function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;last_10=scan(phone,3,' ');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2024 14:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937349#M368308</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-27T14:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937350#M368309</link>
      <description>&lt;P&gt;This is not difficult for SAS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  dsn;
length phone $ 50; 
input phone phone phone;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But why would you want to prohibit the most useful tools.&amp;nbsp; To illustrate, here's a task for you.&amp;nbsp; Try to eat a bowl of cereal and milk without using a spoon.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2024 13:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937350#M368309</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-07-27T13:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937366#M368316</link>
      <description>&lt;P&gt;It looks like&amp;nbsp; an interview question ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  dsn;
input phone $ 50.;
length dummy $ 12;
dummy=phone;
want=strip(tranwrd(phone,dummy,' '));
drop dummy;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Jul 2024 02:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937366#M368316</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-28T02:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937388#M368323</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is not difficult for SAS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  dsn;
length phone $ 50; 
input phone phone phone;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But why would you want to prohibit the most useful tools.&amp;nbsp; To illustrate, here's a task for you.&amp;nbsp; Try to eat a&lt;STRIKE&gt; bowl&lt;/STRIKE&gt; of cereal and milk without using a spoon or bowl.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Expanded for a closer approximation to OP restrictions. (just to be a smart alec &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 13:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937388#M368323</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-28T13:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937389#M368324</link>
      <description>&lt;P&gt;another stupid way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data  dsn;
input phone $ 50.;
l=length(phone);
length newstring $ 10;
do i=(l-10) to l;
   c=char(phone,i);
   newstring=cats(newstring,c);
end;
drop l c;
cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
run;&lt;/PRE&gt;
&lt;P&gt;or reading the data to just read those 10 characters&lt;/P&gt;
&lt;PRE&gt;data  dsn;
input @13 phone $ 10.;

cards;
S001 110064 9873628374
S002 110065 8447752736
S003 110023 9811537264
;
run;&lt;/PRE&gt;
&lt;P&gt;Personally I would ask "how exhaustive is that example input"? If the lengths of the "last" part of that record change the approach might change such as what would be expected if reading&lt;/P&gt;
&lt;P&gt;5004 1101 7234567&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 13:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937389#M368324</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-28T13:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937390#M368325</link>
      <description>&lt;P&gt;Yes, probably an interview question or a homework assignment. If an interview question, this makes me angry, I would want the interviewer to find out if the candidate knows to use the SCAN function in this situation. Some interviewers want to see if the candidate can "think on their feet" when faced with unexpected restrictions, in which case this is a particularly poor way to find that out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have told this story before, but I'll tell it again. Years ago, I took over SAS and statistical support for a department, the previous person having left the company. I began trying to understand the code left behind by the previous person. I found many places where there were 10-15 lines of data step code which I didn't understand. I worked through the code, line by line, and came to the conclusion that these 10-15 lines of data step code were simply adding a column of zeros and ones. Shocked, I thought that can't be right, and did it again, and came to the same conclusion. This decision to add zeros and ones with 10-15 lines of data step code not only cost my company time (for the original programmer to develop this code compared to using PROC SUMMARY) but also cost the company time for me to understand it and replace the code with PROC SUMMARY. Perhaps, some interviewer was happy that the previous person at that job could write such convoluted code; I would not be happy if an interviewer at my company used the question in the original post; and I would not be happy if an interviewer at my company wanted a candidate to not use obvious tools and come up with a convoluted way to perform a task.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 16:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937390#M368325</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-28T16:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937397#M368328</link>
      <description>&lt;P&gt;If this is an interview question, then I doubt it would be worth working for a company asking such dumb questions.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 22:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937397#M368328</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-07-28T22:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937399#M368330</link>
      <description>&lt;P&gt;I think that "previous person" has too poor programming skill to perform the same task or just is a sas rookie don't konw how to enhance the code by "PROC SUMMARY".&lt;BR /&gt;I also meet a person who don't know how to calculate the years between two date by INTCK() or YRDIF(), just divide its range by 365.25&lt;BR /&gt;&lt;BR /&gt;Anyway, any seasoned sas programmer is coming from a rookie.&lt;BR /&gt;Essentially, I think that reason is sas is a very little used programming language.People&amp;nbsp; would barely like to learn it (unlike Python,Java,C#) due to hard to find a job. The company is too difficult to find a good sas programmer .&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 00:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937399#M368330</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-29T00:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937400#M368331</link>
      <description>ballardw,&lt;BR /&gt;CHAR(i) is just another version of SUBSTR(i,1)</description>
      <pubDate>Mon, 29 Jul 2024 00:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937400#M368331</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-29T00:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937411#M368336</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your solution&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 07:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937411#M368336</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-07-29T07:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937412#M368337</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approch&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data e;
set dsn;
r=kupdate(phone,1,find(strip(phone)," ",-length(phone)),trim(' '));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jul 2024 07:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937412#M368337</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-07-29T07:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937414#M368338</link>
      <description>It is the first time I heard of KUPDATE() function.&lt;BR /&gt;I quickly check its documentation in support.sas.com , it is more like a left-side SUBSTR() function.&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0uev77ebdwy90n1rsd7hwjd2qc3.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0uev77ebdwy90n1rsd7hwjd2qc3.htm&lt;/A&gt;</description>
      <pubDate>Mon, 29 Jul 2024 07:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937414#M368338</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-29T07:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937468#M368365</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;ballardw,&lt;BR /&gt;CHAR(i) is just another version of SUBSTR(i,1)&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And the Char documentation says it returns same as SUBPAD(string, position, 1). But default length from Subpad would be 200.&lt;/P&gt;
&lt;P&gt;Length of returned variables will differ if not assigned beforehand. SUBSTR will create a variable the length of the base string variable, Char creates variable with length 1. So not exactly the same.&lt;/P&gt;
&lt;P&gt;But the silly restrictions say SUBSTR specifically, not CHAR.&amp;nbsp; Any such artificial restriction I would say opens up any alternative. Didn't even go the SUBSTRN (also not explicitly restricted) route.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is an interview question and I come up with more functions than the interviewer knows to restrict the result should be what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 15:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937468#M368365</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-29T15:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: extract last 10 digits</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937545#M368383</link>
      <description>Maybe interviewer  ask this question for just showing himself brilliant programming skill ?</description>
      <pubDate>Tue, 30 Jul 2024 00:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-last-10-digits/m-p/937545#M368383</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-30T00:35:50Z</dc:date>
    </item>
  </channel>
</rss>

