Hi,
Like shown in the screenshot, Michigan is misspelled as Michiigan and I'm suppose to fix the error.
Here is what I have:
data Location;
rename Michiggan = Michigan;
run;
Can anyone tell me what I did wrong please? Thank you.
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;
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;
Thank you. It worked.
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
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).
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.
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.
Ready to level-up your skills? Choose your own adventure.