<?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: Renaming and observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598564#M172628</link>
    <description>Thank you so much that worked!!&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Oct 2019 23:51:19 GMT</pubDate>
    <dc:creator>dkeuch816</dc:creator>
    <dc:date>2019-10-22T23:51:19Z</dc:date>
    <item>
      <title>Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598518#M172602</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am importing data over from an excel sheet into Sas EG. I have to create a new data set from that data where there are no mispellings, extra spaces, etc. I have a Character Variable, Subject, where some of it's observations are mispelled and i need to fix them. please help with the correct data step procedure.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 20:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598518#M172602</guid>
      <dc:creator>dkeuch816</dc:creator>
      <dc:date>2019-10-22T20:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598543#M172614</link>
      <description>&lt;P&gt;Not a trivial exercise and made harder by not providing any example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What types of values do you have? People names (misspelling almost impossible to address), company names, City names, drugs, machinery ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do &lt;STRONG&gt;you&lt;/STRONG&gt; know what the correct spellings should be for things? Are the misspellings in the middle of other text such as the middle of a sentence?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have single values that is misspelled such as "BIM" instead of "IBM" then there are tests that can be done to determine if the word is similar to another word and if similar enough you might replace it with a value from a known list. But we would kind of need to have some examples of the misspelled value and the correct value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of if feeling brave Excel does have a spell checker with autocorrect&amp;nbsp;built in. Try that before importing.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 21:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598543#M172614</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-22T21:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598549#M172616</link>
      <description>&lt;P&gt;These are usually brute force unfortunately, unless you have systematic rules that need to be applied.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data clean;
set sashelp.class;

if name = 'Alfred' then name = 'Alfie';
else if name = 'John' then name = 'Johnny';

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&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/182468"&gt;@dkeuch816&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;I am importing data over from an excel sheet into Sas EG. I have to create a new data set from that data where there are no mispellings, extra spaces, etc. I have a Character Variable, Subject, where some of it's observations are mispelled and i need to fix them. please help with the correct data step procedure.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 22:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598549#M172616</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-22T22:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598553#M172619</link>
      <description>I need to change acconting to accounting and mth to match. Its a dataset of teachers and subject is a table implying the subject they teach. I tried&lt;BR /&gt;If subject=acconting then subject=accounting. All that did was create a new variable and list all values as missing.&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Oct 2019 22:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598553#M172619</guid>
      <dc:creator>dkeuch816</dc:creator>
      <dc:date>2019-10-22T22:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598554#M172620</link>
      <description>Note the quotes in my code. You can run that by the way, sashelp.class hould exist on your system.</description>
      <pubDate>Tue, 22 Oct 2019 22:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598554#M172620</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-22T22:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598559#M172625</link>
      <description>&lt;P&gt;Here is an alternate approach using a format that will do the same thing that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s example does.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $rename
'Alfred' = 'Alfie'
'John'   = 'Johnny'
;
run;

data example;
   set sashelp.class;
   name = put(name,$rename.);
run;&lt;/PRE&gt;
&lt;P&gt;The format used this way can seriously reduce the number of IF/THEN/ELSE or other logic statements. And if you are doing this repeatedly with multiple data sets such that new errors appear they can be easily added to the format.&lt;/P&gt;
&lt;P&gt;Suppose I have developed a format that works for your example for accounting which could look like:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $rename
'acconting' = 'accounting'
;
run;&lt;/PRE&gt;
&lt;P&gt;and then the next time a file needs to be processed you find a value of 'acounting'. Just add it to the format:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $rename
'acconting', 'acounting' = 'accounting'
;
run;&lt;/PRE&gt;
&lt;P&gt;No additional code changes need be made.&lt;/P&gt;
&lt;P&gt;This format approach works because any value that does not appear on the left of an = sign in the value block is not reformatted. So the correct values are left alone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: From the description I would suspect that you might be changing "mth" to "math" not "match".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you can get a reasonable start on the values that go on the left by using code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc sql;
    select distinct subject
    from yourdataset
    ;
quit;&lt;/PRE&gt;
&lt;P&gt;Which will create a list in the results window of all the values of subject that you can copy and paste into the editor for proc format. Remove the correct spellings. The value lists in proc format do not have to be all on one line so making a value statement like this should be moderately easy.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $rename
'acconting' , 
'acounting' = 'accounting'
'matth' ,
'mth'    = 'math'
;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 22:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598559#M172625</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-22T22:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598564#M172628</link>
      <description>Thank you so much that worked!!&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Oct 2019 23:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598564#M172628</guid>
      <dc:creator>dkeuch816</dc:creator>
      <dc:date>2019-10-22T23:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598581#M172633</link>
      <description>&lt;P&gt;If your data volume is small enough, what I would do is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Get a distinct list of your subjects (either proc sort nodupkey or proc sql select distinct)&lt;/P&gt;
&lt;P&gt;* Review the distinct list of data.&lt;/P&gt;
&lt;P&gt;* For misspelled data, create a column such as correct_spelling with the correct spelling.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've now just created your custom dictionary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With each new data feed, append to your custom dictionary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rejoin back to your data, assigning correct_spelling to subject where correct_spelling is not missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The compbl function can help with multiple spaces:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   have='This is  a    string with   multiple        spaces';
   want=compbl(have);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Oct 2019 02:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-and-observation/m-p/598581#M172633</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-10-23T02:23:31Z</dc:date>
    </item>
  </channel>
</rss>

