<?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: cannot identify the specific strings in the variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681836#M206307</link>
    <description>&lt;P&gt;Your strings have carriage return and linefeed characters in them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq ;
tables rating ;
format rating $hex10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;The FREQ Procedure

                                       Cumulative    Cumulative
rating        Frequency     Percent     Frequency      Percent
---------------------------------------------------------------
420D0A2020           7       14.00             7        14.00
422B0D0A20           9       18.00            16        32.00
422D0D0A20          15       30.00            31        62.00
42420D0A20           3        6.00            34        68.00
42422D0D0A           6       12.00            40        80.00
4242420D0A           1        2.00            41        82.00
4242422B0D           1        2.00            42        84.00
4343430D0A           1        2.00            43        86.00
4343432B0D           3        6.00            46        92.00
4E520D0A20           4        8.00            50       100.00
&lt;/PRE&gt;
&lt;P&gt;How did you make them?&amp;nbsp; You can use COMPRESS() function to remove them:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rating=compress(rating,'0D0A'x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Sep 2020 22:31:12 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-09-05T22:31:12Z</dc:date>
    <item>
      <title>cannot identify the specific strings in the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681834#M206305</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a new variable (i.e.,&amp;nbsp;SP_20scale) based on the old variable (i.e.,&amp;nbsp;rating) by following codes,&lt;/P&gt;&lt;PRE&gt;data SP_table2;                       
	Length                              
	SP_20scale 8.                                             
	;                                   
	set SP_table1;                      
	if rating='AAA'  then SP_20scale=20;
	if rating='AA+'  then SP_20scale=19;
	if rating='AA'   then SP_20scale=18;
	if rating='AA-'  then SP_20scale=17;
	if rating='A+'   then SP_20scale=16;
	if rating='A'    then SP_20scale=15;
	if rating='A-'   then SP_20scale=14;
	if rating='BBB+' then SP_20scale=13;
	if rating='BBB'  then SP_20scale=12;
	if rating='BBB-' then SP_20scale=11;
	if rating='BB+'  then SP_20scale=10;
	if rating='BB'   then SP_20scale=9 ;
	if rating='BB-'  then SP_20scale=8 ;
	if rating='B+'   then SP_20scale=7 ;
	if rating='B'    then SP_20scale=6 ;
	if rating='B-'   then SP_20scale=5 ;
	if rating='CCC+' then SP_20scale=4 ;
	if rating='CCC'  then SP_20scale=3 ;
	if rating='CCC-' then SP_20scale=2 ;
	if rating='C'    then SP_20scale=1 ;
	if rating='SD'   then SP_20scale=1 ;
	if rating='CC'   then SP_20scale=1 ;
	if rating='D'    then SP_20scale=1 ;
run;                                  &lt;/PRE&gt;&lt;P&gt;However, the code cannot identify the value in the 'rating' variable, I put a sample of the dataset in the attachment, the 'rating' variable is created by following codes,&lt;/P&gt;&lt;PRE&gt;rating=strip(tranwrd(scan(SP_ECR_History1,i,':'),'Rating Range',''));&lt;/PRE&gt;&lt;P&gt;it should not cause by &lt;SPAN&gt;leading and trailing blanks. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you please give me some suggestions about this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 22:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681834#M206305</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2020-09-05T22:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: cannot identify the specific strings in the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681836#M206307</link>
      <description>&lt;P&gt;Your strings have carriage return and linefeed characters in them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq ;
tables rating ;
format rating $hex10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;The FREQ Procedure

                                       Cumulative    Cumulative
rating        Frequency     Percent     Frequency      Percent
---------------------------------------------------------------
420D0A2020           7       14.00             7        14.00
422B0D0A20           9       18.00            16        32.00
422D0D0A20          15       30.00            31        62.00
42420D0A20           3        6.00            34        68.00
42422D0D0A           6       12.00            40        80.00
4242420D0A           1        2.00            41        82.00
4242422B0D           1        2.00            42        84.00
4343430D0A           1        2.00            43        86.00
4343432B0D           3        6.00            46        92.00
4E520D0A20           4        8.00            50       100.00
&lt;/PRE&gt;
&lt;P&gt;How did you make them?&amp;nbsp; You can use COMPRESS() function to remove them:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rating=compress(rating,'0D0A'x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 22:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681836#M206307</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-05T22:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: cannot identify the specific strings in the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681840#M206308</link>
      <description>&lt;P&gt;Use a custom informat to map a string value to a corresponding numeric value.&amp;nbsp; The INPUT function is used to apply the custom informat.&amp;nbsp; Per&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;the original rating value needs to be cleaned up by removing 'unprintable' characters.&amp;nbsp; The COMPRESS function defines a printable character as one with an ASCII code &amp;gt;= 32.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;proc format;
  invalue ratescale
    'AAA' = 20
    'AA+' = 19
    'AA'  = 18
    'AA-' = 17
    'A+'  = 16
    'A'   = 15
    'A-'  = 14
    'BBB+'= 13
    'BBB' = 12 
    'BBB-'= 11 
    'BB+' = 10 
    'BB'  =  9 
    'BB-' =  8 
    'B+'  =  7 
    'B'   =  6 
    'B-'  =  5 
    'CCC+'=  4 
    'CCC' =  3 
    'CCC-'=  2 
    'C'   =  1 
    'SD'  =  1 
    'CC'  =  1 
    'D'   =  1 
    other =  .  /* NR or unknown ratings */
  ;
run;

data want;
  set download.sp_table2;

  rating = compress(rating,,'KW'); * keep only printable characters;

  scale = input (rating,ratescale.);&lt;BR /&gt;  format scale 4.;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Sep 2020 00:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681840#M206308</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-09-06T00:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: cannot identify the specific strings in the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681866#M206319</link>
      <description>Using &lt;BR /&gt;if rating =:  'AAA'&lt;BR /&gt;&lt;BR /&gt;Not&lt;BR /&gt;if rating='AAA'</description>
      <pubDate>Sun, 06 Sep 2020 11:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cannot-identify-the-specific-strings-in-the-variable/m-p/681866#M206319</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-09-06T11:20:51Z</dc:date>
    </item>
  </channel>
</rss>

