BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aabbccwyt
Obsidian | Level 7

Hi, 

Like shown in the screenshot, Michigan is misspelled as Michiigan and I'm suppose to fix the error. 

Screen Shot 2019-12-03 at 9.52.00 PM.png

Here is what I have:

data Location;
        rename Michiggan = Michigan;
run;

Can anyone tell me what I did wrong please? Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

I believe you should have a sas dataset with column A info, if yes, then you should try the below code

 

 

data Location;
set have;
        if columnA='Michiggan' then columnA = 'Michigan';
run;
Thanks,
Jag

View solution in original post

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

I believe you should have a sas dataset with column A info, if yes, then you should try the below code

 

 

data Location;
set have;
        if columnA='Michiggan' then columnA = 'Michigan';
run;
Thanks,
Jag
aabbccwyt
Obsidian | Level 7

Thank you. It worked.

unison
Lapis Lazuli | Level 10

Hi there try:

 

data have;
location='Michiggan, MI';
output;
location='Ohio, OH';
output;
run;

data want;
set have;
if scan(location,1,',','it')='Michiggan' then location='Michigan, MI';
run;

 

-unison

-unison
ballardw
Super User

RENAME is used to change the Name of a variable, the values of a variable.

 

Hint: if you are going to work with address type date, city and state as shown, you should have a separate column for the City and separate for the State. Best is to accomplish this as the data is brought into SAS.

 

If your data has a ZIP code value you might want to investigate the ZIPCITY function.

 

data example;
    zip=49861;
    city = zipcity(zip);
run;

Which returns "Michigamme, MI"

So you may also want to check what the actual correct value is supposed to be. Is that supposed to be the STATE name in long form (in which case your Atlanta, GA is questionable) or the name of a city in the state (I don't find a city named Michigan though there is a Michigan Center  ZIP=49254).

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 923 views
  • 3 likes
  • 4 in conversation