<?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: creating a variable based on the last non-digit-string in another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable-based-on-the-last-non-digit-string-in/m-p/750117#M235870</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387166"&gt;@owndan&lt;/a&gt;, welcome to the SAS Communities forum and thanks for supplying the data in the form of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the following help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;

   length car_brand $ 10;
   retain car_brand;

   if notdigit(strip(id)) then
      car_brand = id;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jun 2021 08:41:22 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2021-06-24T08:41:22Z</dc:date>
    <item>
      <title>creating a variable based on the last non-digit-string in another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable-based-on-the-last-non-digit-string-in/m-p/750116#M235869</link>
      <description>&lt;P&gt;Hello valued SAS experts,&lt;/P&gt;&lt;P&gt;I am facing the challenge described below and would appreciate an approach/idea on how to solve the problem. My dataset have looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input
        ID $
    ;

    datalines;
        VW
        1
        2
        3
        4
        5
        BMW
        6
        7
        8
        9
        10
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the target dataset want there should be a new variable CAR_BRAND which should be created based on the ID according to the following rule:&lt;BR /&gt;Always fill the variable CAR_BRAND with the last non-digit string from the variable ID. Accordingly, the dataset want should look like this at the end:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    input
        ID $
        CAR_BRAND $
    ;
    
    datalines;
        VW VW
        1 VW
        2 VW
        3 VW
        4 VW
        5 VW
        BMW BMW
        6 BMW
        7 BMW
        8 BMW
        9 BMW
        10 BMW
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance for the help/ideas!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 08:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-variable-based-on-the-last-non-digit-string-in/m-p/750116#M235869</guid>
      <dc:creator>owndan</dc:creator>
      <dc:date>2021-06-24T08:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: creating a variable based on the last non-digit-string in another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable-based-on-the-last-non-digit-string-in/m-p/750117#M235870</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387166"&gt;@owndan&lt;/a&gt;, welcome to the SAS Communities forum and thanks for supplying the data in the form of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the following help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;

   length car_brand $ 10;
   retain car_brand;

   if notdigit(strip(id)) then
      car_brand = id;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 08:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-variable-based-on-the-last-non-digit-string-in/m-p/750117#M235870</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-06-24T08:41:22Z</dc:date>
    </item>
  </channel>
</rss>

