<?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: Removing specific set of characters and a number modification problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/543384#M150206</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248692"&gt;@TheNovice&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So, the problem is that only some ID begin with RCI\. How would i use an If function in tandem to make the change if that is the case?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post more representative data and show your full code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LEFT() doesn't do whatever you think it's doing in your code, it only aligns a variable which has nothing to do with what you're trying to do here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would use FIND/INDEX to search for / to see if you want to use SCAN().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No idea what you tried with SUBSTR(), but if you show your work, we can comment on it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2019 01:57:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-03-15T01:57:55Z</dc:date>
    <item>
      <title>Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542643#M149943</link>
      <description>&lt;P&gt;Hi, I have 2 problems with a data set I need to resolve and hoping someone can guide.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Variable ID = rci\name.lastname . Need to remove rci\ to get name.lastname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Emp_ID number&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If EMP_ID starts with &lt;STRONG&gt;10 &lt;/STRONG&gt;&amp;nbsp;then have to convert to sys ID = &lt;STRONG&gt;1&lt;/STRONG&gt;+ digits after the 0&amp;nbsp; or in other words remove the 0 after the 1 ( always a 7digit sys ID)&lt;/P&gt;&lt;P&gt;E.g. EMP_ID 10980041 = Sys_ID 1980041.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;For this i was thinking of just subtracting 900000 from Emp_ID but is there a better way?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the EMP_ID starts with a 11 or 12 or anything different than 10, add a 1 in front of the EMP_ID&lt;/P&gt;&lt;P&gt;E.g. EMP_ID 12020789 = Sys_ID 112020789 (Always 9 digit Sys_ID).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;For this i would add 10,000,000 but is there a better way ?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 03:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542643#M149943</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-03-13T03:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542646#M149945</link>
      <description>For #1 use SCAN() with \ as the delimiter. &lt;BR /&gt;&lt;BR /&gt;For #2 is it a character or numeric variable?</description>
      <pubDate>Wed, 13 Mar 2019 03:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542646#M149945</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-13T03:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542647#M149946</link>
      <description>&lt;P&gt;Actually, for #2, use SUBSTR() for character variable or SUBSTRN() for a numeric variable and you can use CATT() to concatenate the 1 needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those functions, with an IF/ELSE are enough to solve these problems.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248692"&gt;@TheNovice&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I have 2 problems with a data set I need to resolve and hoping someone can guide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Variable ID = rci\name.lastname . Need to remove rci\ to get name.lastname&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Emp_ID number&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If EMP_ID starts with &lt;STRONG&gt;10 &lt;/STRONG&gt;&amp;nbsp;then have to convert to sys ID = &lt;STRONG&gt;1&lt;/STRONG&gt;+ digits after the 0&amp;nbsp; or in other words remove the 0 after the 1 ( always a 7digit sys ID)&lt;/P&gt;
&lt;P&gt;E.g. EMP_ID 10980041 = Sys_ID 1980041.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;For this i was thinking of just subtracting 900000 from Emp_ID but is there a better way?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the EMP_ID starts with a 11 or 12 or anything different than 10, add a 1 in front of the EMP_ID&lt;/P&gt;
&lt;P&gt;E.g. EMP_ID 12020789 = Sys_ID 112020789 (Always 9 digit Sys_ID).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;For this i would add 10,000,000 but is there a better way ?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 03:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542647#M149946</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-13T03:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542863#M150049</link>
      <description>&lt;P&gt;So, the problem is that only some ID begin with RCI\. How would i use an If function in tandem to make the change if that is the case?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 16:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542863#M150049</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-03-13T16:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542868#M150051</link>
      <description>&lt;P&gt;I did this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;length zip $4;&lt;BR /&gt;zip= left('lan i.d'n);&lt;BR /&gt;if zip in ('RCI\','rci\','Rci\') then d = substr('lan i.d'n,5,50);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Still stuck on the number problem so I will just add and subtract as I stated in my earlier post&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 16:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/542868#M150051</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-03-13T16:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/543384#M150206</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248692"&gt;@TheNovice&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So, the problem is that only some ID begin with RCI\. How would i use an If function in tandem to make the change if that is the case?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post more representative data and show your full code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LEFT() doesn't do whatever you think it's doing in your code, it only aligns a variable which has nothing to do with what you're trying to do here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would use FIND/INDEX to search for / to see if you want to use SCAN().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No idea what you tried with SUBSTR(), but if you show your work, we can comment on it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 01:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/543384#M150206</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-15T01:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565945#M158974</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the massive delay... the final code was:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Need;&lt;BR /&gt;set gl;&lt;BR /&gt;length zip $4;&lt;BR /&gt;zip= left('lan i.d'n);&lt;BR /&gt;if zip in ('RCI\','rci\','Rci\') then d = substr('lan i.d'n,5,50);&lt;BR /&gt;If 'Employee ID'n &amp;lt; 12000000 then V21_ID = 'Employee ID'n - 9000000;&lt;BR /&gt;else V21_ID = 'Employee ID'n + 100000000;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 17:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565945#M158974</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-06-13T17:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565955#M158980</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248692"&gt;@TheNovice&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies for the massive delay... the final code was:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Need;&lt;BR /&gt;set gl;&lt;BR /&gt;length zip $4;&lt;BR /&gt;zip= left('lan i.d'n);&lt;BR /&gt;if zip in ('RCI\','rci\','Rci\') then d = substr('lan i.d'n,5,50);&lt;BR /&gt;If 'Employee ID'n &amp;lt; 12000000 then V21_ID = 'Employee ID'n - 9000000;&lt;BR /&gt;else V21_ID = 'Employee ID'n + 100000000;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can use the colon modifier to test the beginning of a string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if left('lan i.d'n) in: ('RCI\','rci\','Rci\') then d = substr('lan i.d'n,5,50);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if upcase(left('lan i.d'n)) =: 'RCI\' then d = substr('lan i.d'n,5,50);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you storing ID variables as numbers instead of strings?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you have such goofy names for your variables? Why not use normal names that do not contain spaces or periods?&amp;nbsp; Then your code will be a lot easier to type and read. You can use the variable LABEL to store more descriptive information about the variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 18:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565955#M158980</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-13T18:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565968#M158985</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ID variables are numeric because that's how they are stored in other tables that I need to pull data from. Are you suggesting that I convert ID variable to character to then modify?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goofy names are not my doing. I get a flat file from someone and I have to convert the Employee ID to another ID... What would you suggest? I have never used the LABEL statement but i will look into it&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 18:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565968#M158985</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-06-13T18:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565979#M158991</link>
      <description>When you import your data ensure you have set the following first. Then you'll get your data imported correctly. Given that it's a flat file you have total control over how its imported, and whether a variable is character or numeric. It's actually very bad practice to use PROC IMPORT for a repeatable process because you can't guarantee the imports will be the exact same across changes in SAS or file types. It's a very easy way to introduce errors into your process.&lt;BR /&gt;&lt;BR /&gt;options validvarname=v7;</description>
      <pubDate>Thu, 13 Jun 2019 19:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565979#M158991</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T19:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565980#M158992</link>
      <description>&lt;P&gt;If you need it as number to join you might be stuck with it.&amp;nbsp; SAS only has two types of variables. Fixed length strings or floating point numbers.&amp;nbsp; Storing an ID as a number is confusing since you will never want to take the mean or sum the values.&amp;nbsp; Also floating point numbers can only store a maximum of 16 decimal digits exactly.&amp;nbsp; So you can run into trouble if your ID values get too long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wrote the program to read in the data then just use normal names for your variables in your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you used PROC IMPORT to guess what names to use by reading a text file or a spreadsheet you might get much better names if you set the VALIDVARNAME option to V7 instead of ANY.&amp;nbsp; Then PROC IMPORT will convert report headers like "EMPLOYEE ID" that use invalid names into a name like EMPLOYEE_ID instead.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 19:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565980#M158992</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-13T19:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specific set of characters and a number modification problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565986#M158994</link>
      <description>&lt;P&gt;Thanks you so much explaining. I will test immediately!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 19:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-specific-set-of-characters-and-a-number-modification/m-p/565986#M158994</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-06-13T19:32:03Z</dc:date>
    </item>
  </channel>
</rss>

